MimConvert()函数

Synopsis

Perform a color conversion.

Format

MIL_ID MimConvert(SrcImageId, DestImageId, ConversionType)

MIL_ID SrcImageBufId; Source image buffer identifier
MIL_ID DestImageBufId; Destination image buffer identifier
long ConversionType; Type of conversion to perform

Description

This function performs a color conversion on the source image and places the result in the destination buffer.

The SrcImageBufId parameter specifies the identifier of the source image buffer. Source buffer values must be positive. If specifying a floating-point buffer, the values of the buffer must be normalized between 0 and 1 before calling this function.

The DestImageBufId parameter specifies the identifier of the destination image buffer. If specifying a floating-point buffer, the values generated will be normalized between 0 and 1.

The ConversionType parameter specifies the type of conversion to perform. This parameter can be set to one of the following values:

ConversionType Description
M_RGB_TO_HLS An RGB to HLS conversion. The hue, luminance (intensity) and saturation are calculated from the source buffer. Both the source and destination image buffers must be 3-band image buffers allocated with MbufAllocColor.
M_HLS_TO_RGB A HLS to RGB conversion. The Red, Green and Blue components are calculated from the source buffer. Both the source and destination image buffers must be 3-band image buffers allocated with MbufAllocColor.
M_RGB_TO_L An RGB to L (luminance) conversion. The luminance (intensity) is calculated from the source buffer. The source image must be a 3-band image buffer allocated with MbufAllocColor and the destination buffer must be a 1-band image buffer allocated with MbufAlloc2d.
M_L_TO_RGB An L (luminance) to RGB conversion. The Red, Green and Blue components are calculated from the source buffer. The luminance (intensity) is repeated in each color band of the destination buffer, creating a monochromatic (gray) RGB buffer. The source buffer must be a 1-band image buffer allocated with MbufAlloc2d) and the destination buffer must be a 3-band image buffer allocated with MbufAllocColor.

The values generated will be normalized to the range of values in the destination buffer. For example, the hue values from 0 to 360 degrees will generate the values from 0 to 255 in an 8-bit destination buffer. Negative values in signed buffers will return invalid results. Note that for a floating point destination buffer, the values generated will be normalized between 0 and 1.

See also

MbufAllocColor, MbufAlloc2d