Color imaging process
The subject invention was developed under NIH grant 5-RO1-EY03164 and the government has a non-exclusive license for its own use hereunder. 
    
    
     This invention is directed generally to a method and system for measuring true color by estimating the spectral reflectance of surfaces, and relative spectral power of the ambient light. The method does not depend on specific prior knowledge of the ambient light or surfaces in the measured image. 
     Consider viewing a scene first in daylight and then under tungsten light. Despite a marked change in the spectral composition of the illuminating light, the human eye sees little change in the colors of objects in the scene. Man&#39;s perceptual ability to discount spectral variation of the illuminant and thereby maintain the appearance of object colors is called &#34;color constancy.&#34; The mechanism by which color constancy is achieved remains the oustanding problem in the analysis of human color vision. 
     It is an objective of the present invention to sense the light reflected from the objects under study, separately calculate the spectral composition of the ambient light illuminating the objects, and then derive the surface reflectance of each object. 
     The ability to separate the effect of the ambient lighting from the effects of surface reflectance permits the construction of a number of devices that are of value in many different areas, including robotics (computer vision), photography, color measurement and matching, television, video cameras, video recorders, and color image processing and correction systems. 
     For example, robotics visual systems that wish to use surface spectral reflectance (i.e., color) to aid in object recognition and identification must be able to effectively discount any variation in the ambient light. 
     In particular, if a robot is to be trained to sort fruit, it must be able to study the fruit under full daylight, cloudy, or artificial lighting conditions, or a combination of the above, and accurately sort the fruit according to its surface properties, such as color, gloss, etc. 
     It is an objective of the present invention to provide a system and procedure which allows a robot a capability for accurately estimating surface reflectance properties of objects under study, despite incomplete knowledge of the ambient light. 
     A common problem in photography is that different types of film must be used for photography under different lighting conditions. 
     It is an objective of the present invention to provide a method of acquiring and/or processing color images, so that images photographed under one type of ambient light can be reconstructed as though they were shot under a different ambient light, thereby eliminating the need to use different films for different ambient light conditions. 
     Another problem in photography is that different filters must be used by photographers to accommodate different ambient lighting conditions. 
     It is an objective of the present invention to provide a method of buiding a light meter that can estimate the spectral properties of the ambient light, and use the results to advise photographers what type of color filter should be used on the camera to properly correct for the film loaded in their camera, or automatically to provide the appropriate color filter. 
     A related objective of the present invention is to provide an approach for incorporating sensors into optical cameras so that proper acquisition, recording, processing, correction and transmission of color images for television displays, video displays video recordings, and other outputs or displays can be carried out. 
     Another problem involving the perception of surface properties of materials has to do with the use of textile dyes, automobile paints, and the like. It is a common occurrence that different batches of dyes are used to color textiles, and objects such as car parts are painted using different batches of paint. 
     It is an objective of the present invention to provide a method and system for analyzing the spectral reflectance properties of different batches of paints and dyes to determine whether they will appear to match well under different ambient lighting conditions. 
     These and other applications depend on the ability to separate the effect of the ambient lighting from the effects of surface reflectance. The method described in the detailed description which follows uses the data sensed by N+1 sensor classes to define a finite dimensional approximation of a surface reflectance function at each image point, and a finite dimensional approximation of the ambient light. The algorithm is able to recover the coefficients that specify these approximations. 
     The fundamental physical components that play a significant role in the surface reflectance sensing method are (a) the ambient light, (b) the surface reflectances, (c) the sensors, and (d) the sensor responses. 
     We describe the ambient light in terms of how much energy is present at each wavelength. We call this function E(λ), where λ represents wavelength of light. We assume the light is uniform across the scene, for the moment, but we show how to relax this assumption later. 
     We describe the surface reflectance in terms of the fraction of the incident light the surface reflects at each wavelength. We call this function S x  (λ); where λ represents wavelength of light and x refers to spatial position. We assume that the objects under study are opaque and perfectly diffusing (matte). 
     There are P independent classes (kinds) of sensors in a two-dimensional array. An image of the scene is formed on this array. We refer to the locations of lights, surface reflectances and sensor responses by the position, x, in the sensor array at which each has its effect, and not by their physical location in the scene. Each class is present in sufficient density in the sensor array to adequately recover the image from the samples taken by the sensors. We describe the sensor spectral sensitivity in terms of the fraction of incident light at each wavelength that is absorbed by the sensor. We call this function R k  (λ) for the k th  class of sensor. 
     The ambient light reflected from a surface will cause a strength of response in the k th  class of sensor, at position x, according to 
     
         ρ.sup.x.sub.k =∫E(λ)S.sup.x (λ)R.sub.k (λ)dλ 
    
     We assume that there are P classes of sensors, and we represent the responses of all the sensors at location x by a vector, ρ x  =(ρ x   1  . . . ρ x   p ) 
     We use two approximating formulas, one to simplify the description of the ambient light and a second to simplify the description of the surface reflectance. These are ##EQU2## These approximating formulas permit us to characterize the light by the vector of weights ε=(ε 1  . . . ε M ) and the surface reflectance at a point, x, by the vector of weights σ x  =(σ x   1  . . . σ x   N ) 
     The relationship between the characterization of the surface reflectance, σ x , and the sensor responses, ρ x  =(ρ x   1  . . . ρ x   p ) can be described by a matrix equation of the form 
     
         ρ.sup.x =Λ.sub.ε σ.sup.x 
    
     where ρ x  and σ x  are vectors, and Λ.sub.ε  is a matrix whose entries depend only on the ambient light. Our algorithm describes a method for recovering the surface reflectance vectors, σ x , and the lighting matrix, Λ.sub.ε, given only the sensor data information, ρ x . By recovery we mean specifically that in each region of the scene over which the ambient light is approximately uniform, we recover the light vector, ε, except for an unknown multiplier, a, and correspondingly we recover estimates of the surface reflectance vectors up to the inverse of this unknown multiplier, (1/a)σ x . Our recovery procedure specifies the relative spectral energy distribution of the ambient light, aE(λ) and a corresponding set of reflectance functions (1/a)S x  (λ). We require that there be at least as many sensor classes P, as there are degrees of freedom in the ambient light approximation (M). We require that there be more classes of sensors, P, than there are degrees of freedom in the surface reflectance approximation (N). 
    
    
     The invention will be described with respect to the following figures: 
     FIG. 1 illustrates the energy spectrum of light radiated from a known light source. 
     FIG. 2 illustrates the surface reflectance of a material at different wavelengths. 
     FIG. 3 comprises a block diagram of the elements of an exemplary system incorporating the present invention. 
    
    
     A description of the physical environment and its relation to the perception of color gives insight into the problem and the novel method disclosed herein to solve it. The objective of the method is to independently determine the ambient light in the scene under examination, then the surface reflectance of the objects. 
     FIG. 1 is a plot of the relative spectral energy distribution of a typical daylight, E(λ). 
     FIG. 2 is a plot of the spectral reflectance (i.e., [S(λ)] tendency to reflect light at different wavelengths) of a particular substance, gold. 
     The light reaching the eye from each object in the scene is then simply E(λ)S x  (λ) where the superscript x refers to the location of the objects, image on the sensor array, and the values are derived from the curves of FIGS. 1 and 2. 
     The initial stage of color vision is the absorption of light by photoreceptors in the eye or optical sensor. Each kind of photoreceptor or sensor has a spectral sensitivity R to each wavelength of light and behaves essentially as a linear system. Different sensors will have a tendency to absorb different wavelengths at different parts of the physical spectrum. The excitation recorded by a photoreceptor of the k&#39;th class is then 
     
         ρ.sup.x.sub.k =∫E(λ)S.sup.x (λ)R.sub.k (λ)dλ 
    
     For example, it is generally accepted that the human eye contains four distinct photoreceptors, three of which are active in daylight (photopic) vision. At each location x, then, the information concerning color is reduced to three numbers, the excitations or &#34;quantum catches&#34; of the three photoreceptor classes at each location. These three numbers are determined by both the spectral distribution of the ambient light E(λ) and the spectral reflectance S x  (λ) of objects at each location. 
     The problem of the surface spectral reflectance estimation may be put as follows. The spectral reflectance at each location S x  (λ) is unknown. At each location, we measure the P quantum catches ρ x   k . We must develop a procedure that estimates the surface reflectance at each location, X, when the ambient light is unknown. If the ambient light E(λ) never varied, then the quantum catches at each location (or some function of the quantum catches) could serve as an estimate. But the same surface may give rise to very different quantum catches under different ambient lights. 
     Intuitively the gist of our procedure can be understood as follows. After sampling s surfaces, sP values are known from the left hand side of the matrix equation. But sN+M values are unknown on the right hand side of the equation. The number of unknowns always exceeds the number of knowns when P is less than or equal to N. The underdeterminancy can be resolved if one uses at least P=N+1 linearly independent sensors to spectrally sample the image at each location. In this case, s(N+1) values are obtained on the left hand side of the equation so that after sampling at M independent locations or more, the equations become overdetermined and can be solved for both ε and σ x . 
     Therefore, N+1 sensor classes will permit recovery of both the lighting parameters, ε, and the surface reflectance parameters, σ x , at each location. 
     The algorithm to accomplish the solution may be implemented as follows: 
     Step 1: Input the sensor data, ρ x , from N+1 or more sensors at each spatial location. The possible set of data values are completely described by these P-dimensional vectors. 
     Step 2: If the finite-dimensional approximating formulas are precisely correct, then the observed data will fall within an N-dimensional subspace of the P-dimensional sensor space. An example of a subspace is the following. Suppose there are P=3 sensors and N=2 terms used to describe the surface reflectance function. Then the sensor data will cluster about a plane passing through the origin in the 3-space. We compute the N-dimensional subspace that best contains all of the observed data. The best-fitting N-dimensional subspace can be obtained in many ways. We use a variant on a principal components decomposition of the sensor data. The first N principal components determine the subspace desired. 
     Step 3: Knowledge of the axes that define the subspace defines a set of linear equations from which it is possible to compute the vector ε that describes the light that would generate data restricted to the best-fitting subspace, based on the approximation ##EQU3## 
     Step 4: Use the estimated ambient light vector to compute the values of the matrix Λ.sub.ε  that maps the vector representation of surfaces (σ x ) into the sensor data (ρ x ), using the approximation ##EQU4## 
     Step 5: Given the values of the matrix, Λ.sub.ε, solve the linear equations in Step 4 to recover the surface reflectance σ x  from the sensor data ρ x  at each location, i.e., 
     
         ρ.sup.x =Λ.sub.ε σ.sup.x 
    
     Actual software written to implement this invention is incorporated herein as Appendix A. The software is written to run under the S software system. 
     S is a software system that runs under Bell Laboratories UNIX operating system on a variety of hardware configurations. S runs primarily on VAX computers made by the Digital Equipment Corporation; the code in Appendix A is written for such a computer, specifically a DEC VAX/780, running the 4.2BSD UNIX operating system. S is available through AT&amp;T Technology. 
     The number of parameters required to have adequate models of ambient lights and surfaces may often be rather small. What data is available concerning spectral reflectances suggests that only a small number of parameters are needed to model most naturally occurring spectral reflectances. Recall that the number of sensors needed to capture N components of reflectance is at least N+1. We take the fact that biological systems have evolved with a rather small number of sensors as an indication that the number of degrees of freedom required to adequately represent spectral reflectance functions may also be quite small. 
     In many natural images, the spectral composition of the illuminant varies with spatial location. The computation above can be extended in a straightforward manner to the problem of estimating and discounting a slowly-varying (spatial lowpass) ambient light. For such images, in each local region the ambient light is approximately constant. The algorithm may thus be applied to each such local region of the image. 
     The new formulation also specifies how to construct automatic sensor systems capable of discounting spectral fluctuations in the ambient lighting. Using the analysis provided here the design of such systems can be specially tailored to working environments where the range of surfaces and lights may be measured before sensing begins. 
     A block diagram of an illustrative system incorporating the present invention appears in FIG. 3. An array of sensors 10 is provided facing the object surfaces to be examined. At least one more sensor class need be provided than there are degrees of freedom in the surface reflectance elements to be examined. As discussed above, sensors might include a camera with N+1 sensors responsive to every point of interest on the object; N+1 emulsions on film; or other types of (N+1) sensor arrays. The collected data (ρ x ) is processed 12 to develop the values of σ x  (surface reflectance) and ε x  (ambient light) needed to define every point on the surface in terms of both the surface spectral reflectance and the ambient light at each point on the object surface. With this information it is then possible, using conventional techniques of color science, to compute 14 the CIE (Committee Internationale d&#39;Eclairage) color tri-stimulus coordinates that should be output on the display device 16 at each point. From the knowledge of these values, we may compute exactly what should be displayed on a wide variety of color display media or printing devices or systems. The method of converting from our parameter estimates to display coordinates has two steps: first, we describe how to compute the standard CIE color coordinates. Then we describe the relationship between these coordinates and various common displays. 
     The values of the surface reflectance vector σ x  permit us to estimate the surface spectral reflectance at point x by ##EQU5## Similarly the vector ε defines an estimate of the ambient light, ##EQU6## 
     To compute the value of X in the CIE tri-stimulus color coordinate system, often called the X, Y, Z system, we need only to perform the following numerical integration: ##EQU7## 
     A precisely parallel computation, substituting y(λ) and z(λ), be made to compute Y and Z. The functions E and S are estimated by our procedure. The functions x(λ),y(λ),z(λ) are defined by the CIE and their values are widely available. Table 3.2 in Wyszecki and Stiles (1967, Color Science published by John Wiley &amp; Sons), incorporated herein by reference, contains the values of these functions. 
     The values X, Y, Z precisely determine the desired output color for any particular device in terms of an agreed upon international color standard devised by the CIE. In order to specify the exact values required for some particular display device, it is only necessary to translate CIE color coordinates into device dependent coordinates. For example, the color coordinate system defined by the United States National Television Standards Committee (NTSC) is called the Y,I,Q system. In order to drive a color television monitor 16 one can use a simple set of linear formulas, equivalent to a matrix multiplication, that converts X,Y,Z to Y,I,Q; given these values, it is well known in the art how to make the necessary conversions 14 to drive the television guns to display each point x on the television screen 16. The relationship between the values of Y,I,Q and X,Y,Z are specified by the matrix equation 
     
         Y=0.0X+1.0Y+0.0Z 
    
     
         I=0.407X-0.842Y-0.451Z 
    
     
         Q=0.932X+1.189Y+0.233Z 
    
     A table of conversions that are common between various color representations, including the values to convert from X,Y,Z, coordinate system to Y,I,Q we have just described, from Pratt&#39;s widely used book entitled Digital Image Processing, (John Wiley &amp; Sons 1978) is incorporated herein by reference. Procedures for converting from X,Y,Z specifications to any conventional device used in color display technology, such as film, video recorders, etc. 
     Because our algorithm estimates both the surface spectral reflectance and the ambient light, it allows the user great flexibility during image display in any of these media. The user may represent the results veridically, by using only the actually estimated values to determine the actual display values. Alternatively, the user may wish to display the results as if they were measured under conditions that did not exist at the time of image acquisition. To accomplish the user may display the colors using a light, E(λ), that is different from the actually obtained estimate of ε. The resulting display will have the appearance of being acquired under the assumed ambient light conditions, which may be quite different from the conditions under which the image was actually obtained. 
     For example, if the image was acquired under diffuse tungsten light, the procedure permits a reconstruction of the image as if the image had been acquired under diffuse fluorescent light, sunlight, or any other desired ambient light. 
     Other modifications to the present invention may occur to a person of skill in the art who studies the subject invention disclosure. Therefore, the present invention is to be limited in scope only by the following claims. 
     
         ______________________________________                                    
 Appendix A                                                               
______________________________________                                    
#                                                                         
# Single Region Spectral Reflectance Estimation Algorithm                 
# Larry Maloney, Unpublished Work,   9.17.84                              
#                                                                         
# Initialization                                                          
#                                                                         
# Set up constants and data structures prerequisite to                    
# the algorithm                                                           
#                                                                         
#                                                                         
nL - 20  # number of locations                                            
nE - 4   # dimension of light space                                       
nS - 3   # dimension of surface reflectance space                         
nR - 4   # number of photoreceptors                                       
# The identity matrix [nR × nR]                                     
 ##STR1##                                                                 
# The system lambdai: nE matrices each [nR × nS]                    
# The values lambda1 - lambda4 are based on                               
# EinE basis elements chosen to be the mean                               
#and first three components of daylight across                            
#as given in of Judd, MacAdam Wyszecki(1964).                             
#Scaled to unit norm.                                                     
#                                                                         
# SjnS basis elements chosen to be the characteristic                     
#vectors of the Munsell chips across the range                            
#400-700nm inclusive at 10nm intervals as given                           
#in Cohen(1964).                                                          
#Scaled to unit norm.                                                     
#                                                                         
# Rk nR sensor sensitivities based on the Smith-Pokorny                   
#spectral sensitivities given in Boynton(1979)                            
#Scaled to unit norm.                                                     
#                                                                         
# The kj&#39;th entry of lambdai is then sum ( Ei*Sj*Rk ).                    
tmp - matrix( read(&#34;lambda.system&#34;), ncol=4, byrow=T )                    
lambda1 - tmp[ 1:4, 2:4]                                                  
lambda2 - tmp[ 5:8, 2:4]                                                  
lambda3 - tmp[ 9:12, 2:4]                                                 
lambda4 - tmp[13:16, 2:4]                                                 
#                                                                         
#                                                                         
# Single Region Spectral Reflectance Estimation Algorithm                 
# Larry Maloney, Unpublished Work,   9.17.84                              
#                                                                         
# Estimation                                                              
#                                                                         
# Given the quantum catches and the lambdai matrices                      
# representing the operating characteristics of the                       
# vision system, estimate the light vector epsilon                        
# and the surface reflectance vectors sigma.                              
#                                                                         
# Assumed: nS+1 = nE = nR                                                 
#                                                                         
#                                                                         
# ESTIMATE EPSILON STAR                                                   
#                                                                         
# Augment quantum catches rho by the same vectors with opposite           
# sign. Perform a principle components decomposition to find              
# best nS-space constrained to pass through origin to the                 
# data rho.                                                               
#                                                                         
mirror - cbind( rho, -rho)                                                
pr - prcomp(t(mirror))                                                    
# An orthonormal basis for best nS-space is the first nS columns          
of pr.                                                                    
# The last principal component is perpendicular to this best nS-space     
# and serves as an estimates of epsilon star                              
epsperp - pr$rot[,nS+1]                                                   
# ESTIMATE EPSILON                                                        
# Compute delta matrix                                                    
delta - cbind( t(lambda1) %* epsperp, t(lambda2) %* epsperp,              
 t(lambda3) %* epsperp, t(lambda4) %* epsperp)                            
eig - eigen( t(delta) %* delta )                                          
epshat - eig$vectors[,1]                                                  
epshat - epshat/sqrt(sum(epshat 2)) # the normalized estimate             
of epsilon                                                                
 # epshat is determined up to a sign. For convenience in                  
 # evaluation choose sign to minimize angular discrepancy with            
 # epsilon.                                                               
 if ( sum(epsilon*epshat)&lt;0 ) epshat - -epshat                            
 #                                                                        
 erreps - epsilon-epshat                                                  
 round(epsilon,5); round(epshat,5); round(erreps,5)                       
# Compute lambhat the estimated lambda sub epsilon                        
# Compute lambda sub epshat                                               
lambda - epshat[1]*lambda1 + epshat[2]*lambda2 +                          
epshat[3]*lambda3 + epshat[4]*lambda4                                     
# ESTIMATE SIGMAs                                                         
sighat - reg(lambda,rho,int=F)$coef                                       
#                                                                         
#                                                                         
# Single Region Spectral Reflectance Estimation Algorithm                 
# Larry Maloney, Unpublished Work   9.17.84                               
#                                                                         
# Generate test data for a single (constant light) region.                
#                                                                         
# Choose random surface reflectances and lights                           
# for test purposes.                                                      
# Generate corresponding sensor quantum catches.                          
#                                                                         
# Perturb quantum catches with Gaussian error as                          
# controlled by sdS, sdE to test robustness of                            
# algorithm.                                                              
#                                                                         
# NB: sdS and sdE must be defined before execution.                       
#                                                                         
#                                                                         
# LIGHT                                                                   
# Choose a random light vector and normalize it.                          
epsilon - rnorm(4)                                                        
epsilon - epsilon/sqrt(sum(epsilon 2))                                    
# Compute lambda sub epsilon                                              
lambda - epsilon[1]*lambda1 + epsilon[2]lambda2 +                         
epsilon[3]*lambda3 + epsilon[4]*lambda4                                   
# SURFACE REFLECTANCES                                                    
#  choose random surfaces vectors sigma[nS,nL]                            
sigma - matrix( rnorm(3*nL),nrow=3)                                       
# SENSOR QUANTUM CATCHES                                                  
# Compute the quantum catches and perturb them. Perturbations are         
# Gaussian random variables. The values pertS correspond to               
# Gaussian error with mean 0 and variance sdS 2 that is added             
# to each sensor type at each point in the scene independently.           
# The values pertE are Gaussian errors with mean 0 and variance           
# sdE 2 added to each sensor class independently                          
# but the same errors are added at every location in the scene.           
#                                                                         
# The errors pertS correspond to errors introduced by the surfaces.       
# The errors pertE correspond to errors introduced by the light.          
#                                                                         
pertS - matrix( rnorm(4*nL,0,sdS),nrow=4)                                 
pertE - matrix(rep(rnorm(4,0,sdE),nL),nrow=4)                             
#                                                                         
# Compute sensor quantum catches                                          
#                                                                         
 ##STR2##                                                                 
______________________________________