Appendix E: Program Code

Marc Ebner · 2006

All of the algorithms in the subsequent text are described in pseudocode.Note that this code will not compile as stated.It is meant to illustrate how the algorithms work.In order to get a code that will compile using C++, Java, or any other programming language, you will have to fill in the necessary details.The code shown here is meant to be as simple as possible in order to show what the algorithms do and how they work.Operators such as addition (+), subtraction (-), multiplication (*), or division (/) are understood to work with the individual components of the image.When the code is OutputImage=InputImage/maxValue and maxValue is a scalar value, it is meant thatwhere the parameters x and y refer to image coordinates and the parameter b refers to the image band.When the code is OutputImage=InputImage*m and m is a three-element vector, it is meant thatAlso, some optimizations can be made in order to speed up the code.For instance, instead of sorting all image values as is done in the pseudocode of the white patch retinex algorithm or the pseudocode of the gray world assumption, one may also compute a histogram and then compute the clip values from the histogram.In order to simplify the code further, some variables as well as functions are assumed to be common to all algorithms.Error checking has been omitted.Image values are taken to be from the range [0, 1], i.e. we haveImage values are assumed to be linear.If you process image data where the image is stored using the sRGB color space, you will need to linearize the data as described in Chapter 5. Similarly, the computed output image OutputImage will also contain linear Color Constancy M. Ebner

Read the paper · More papers on PaperTik