Description Converts an image consisting of tristimulus XYZ values to an RGB image, which can then be written to a bitmap file using the RGBToBitmap routine.
Syntax XYZImageToRGBImage X, Y, Z, Brightness, R, G, B, NOutOfGamut
Parameters X() As Double The array of tristimulus X values
Y() As Double The array of tristimulus Y values
Z() As Double The array of tristimulus Z values
Brightness As Double Overall scale factor applied to XYZ values before conversion
R() As Integer An array returning the Red values ranging between 0 and 255
G() As Integer An array returning the Green values ranging between 0 and 255
B() As Integer An array returning the Blue values ranging between 0 and 255
NOutofGamut As Long An integer returning the number of pixels that have colors lying outside the gamut of the colorspace
Remarks XYZImageToRGBImage converts an image consisting of tristimulus XYZ values to an RGB image, which can then be written to a bitmap file using the RGBToBitmap routine. If there is a problem the subroutine sets an error and returns without modifying any of the parameters.
The conversion of each pixel is performed in the following way: 1. The X, Y, and Z values are divided by the image's maximum Y (luminosity) value, and then multiplied by the specified brightness factor. 2. The X, Y, and Z values are transformed into their corresponding R, G, and B values, using a matrix formed from the primary colors and white point of the current color space. 3. R, G, and B components that lie outside the range 0 to 1 are outside the gamut of the current color space. They are clipped to the range 0 to 1 and counted as out-of-gamut. 4. At this point the RGB values are still in linear space. They are next gamma-adjusted using the value of gamma specified with the current color space. 5. RGB values are multiplied by 255, turned into integers, and copied to the output image arrays. FRED uses the sRGB color space, which has a gamma of 2.2. This is not currently changeable.
Because of the scaling performed in step 1 the brightest (highest luminosity) input pixel will be mapped to a fully bright output pixel. There can be situations where this isn't desirable. For example, an input image of all dark gray pixels will result in an output image of all white pixels. This can be corrected for by setting the brightness parameter to a value less than 1.
See Also
|