MIL_ID Src1Id, | //in |
MIL_ID Src2Id, | //in |
MIL_ID DestId, | //in |
MIL_ID MaskId, | //in |
MIL_ID DistanceAttributesArrayId, | //in |
MIL_INT64 DistType, | //in |
MIL_DOUBLE NormalizeValue, | //in |
MIL_INT64 ControlFlag | //in |
This function calculates the point-to-point distance between colors in two images. You can also calculate the point-to-point distance between the color in one image and: a color constant, a covariance matrix, or the covariance of a specified image. The calculated distance (for each pixel) is written in the specified destination image (DestId parameter). To ignore unwanted pixels in the distance calculation, you can apply a mask.
The color distance is typically calculated only for pixels within the intersection of the source (Src1Id and Src2Id), destination (DestId), and mask (MaskId) images, with the assumption of a common origin at the top-left corner.
The Color Analysis module assumes that the color of the images you use with McolDistance() is consistent. For example, you will not receive an error if you try to calculate the distance between an RGB and an HSL image, or a 16-bit and an 8-bit image. Even when color data is inconsistent, it is still processed as is, which can produce misleading results.
You can also obtain distance results after calling McolMatch(), which unlike McolDistance(), considers the color matching context's color space. For more information on how distances differ between these two functions, see the Distance between colors section of Chapter 16: Color processing and analysis.
This function is optimized for planar buffers or for packed 32-bit BGR buffers with a width (X-size) greater than seven pixels (MbufAllocColor()). It is recommended to avoid providing both planar and packed buffers, since this requires some internal compensation.
Specifies the identifier of the first source image buffer. The buffer must be an 8- or 16-bit color (3-band) unsigned image buffer.
This image buffer must not have a region of interest (ROI) associated with it. Using an image buffer with an ROI will cause an error.
Specifies the identifier of the second source buffer, which can be either an image or a MIL array buffer.
For an image, the buffer must be an 8- or 16-bit color (3-band) unsigned image buffer. For an array, the content and size depends on the type of distance operation chosen (DistType).
This image buffer must not have a region of interest (ROI) associated with it. Using an image buffer with an ROI will cause an error.
Note that when setting this parameter to an array buffer, this function will achieve maximal speed performance if the buffer's data type is the same as the data type of the first source image. For example, you will achieve maximal speed if the first source image buffer and second source array buffer are both 8-bit unsigned buffers.
Specifies the identifier of the destination image buffer in which to write the results of the distance calculation. The destination buffer must be a 1-band buffer; its type is not restricted.
This image buffer must not have a region of interest (ROI) associated with it. Using an image buffer with an ROI will cause an error.
Since distance results are numerical values containing decimals, if you specify the destination buffer as type integer, the fractional part of the value will be truncated. For example, a distance of 50.25 will truncate to 50.
Distance results are clipped if they are greater than the destination buffer's maximal possible value. For example, when using an 8-bit unsigned destination buffer, distances higher than 255 will be written as 255. Note that if you specify a destination buffer of type floating-point, distance results would almost never be greater than the buffer's maximal possible value, since its limit is extremely high.
To normalize distance results, use the NormalizeValue parameter.
Specifies the identifier of the image buffer used to identify the masked (non-zero) pixels. This must be a 1- or 8-bit (1-band) unsigned buffer. To not apply a mask, set this parameter to M_NULL.
This image buffer must not have a region of interest (ROI) associated with it. Using an image buffer with an ROI will cause an error.
The color distance is calculated only for masked (non-zero) pixels within the intersection of the source, destination, and mask images, with the assumption of a common origin at the top-left corner. Set unmasked pixels to 0; unmasked pixels are ignored in the distance calculation.
Specifies the type of distance operation to perform. This parameter must be set to one of the following values:
For specifying the distance
type
|
|||||||||||||||||||||||||||||||||||||||
Value | Description
|
||||||||||||||||||||||||||||||||||||||
M_EUCLIDEAN |
Specifies to use a Euclidean color distance. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_MAHALANOBIS |
Specifies to use a Mahalanobis color distance. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_MANHATTAN |
Specifies to use a Manhattan color distance. (more details...) |
Specifies the factor with which to normalize the resulting distances. The normalized distance that is written to the destination buffer must respect this buffer's limits (DestId).
This parameter should be set to one of the following values:
For specifying the normalization of
distances
|
|||||||||||||||||||||||||||||||||||||||
Value | Description
|
||||||||||||||||||||||||||||||||||||||
M_DEFAULT |
Same as M_NO_NORMALIZE. |
||||||||||||||||||||||||||||||||||||||
M_MAX_NORMALIZE |
Specifies to normalize distance values according to the greatest calculated distance. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_NO_NORMALIZE |
Specifies no normalization. (more details...) |
||||||||||||||||||||||||||||||||||||||
Value > 0.0 |
Specifies to normalize distance values according to the specified normalization value. (more details...) |
Header | Include mil.h. |
Library | Use mil.lib; milcolor.lib. |
DLL | Requires mil.dll; milcolor.dll. |