Note: Arithmetic calculations in this table assume 24-bit image data.
The following flags define how to treat the source rectangle:
Value |
Meaning |
CB_SRC_NOP |
[0x00000000] No change. |
CB_SRC_NOT |
[0x00000001] Invert the color, resulting in its complement. |
CB_SRC_0 |
[0x00000002] Change all bits to 0. |
CB_SRC_1 |
[0x00000003] Change all bits to 1. |
The following flags define how to treat the destination rectangle:
Value |
Meaning |
CB_DST_NOP |
[0x00000000] No change. |
CB_DST_NOT |
[0x00000010] Invert the color, resulting in its complement. |
CB_DST_0 |
[0x00000020] Change all bits to 0. |
CB_DST_1 |
[0x00000030] Change all bits to 1. |
The following flags define the operation to use when combining the data:
Value |
Meaning |
CB_OP_AND |
[0x00000000] Combine each set of bytes using a bitwise AND (&). |
CB_OP_OR |
[0x00000100] Combine each set of bytes using a bitwise OR ( | ). |
CB_OP_XOR |
[0x00000200] Combine each set of bytes using a bitwise exclusive OR (^). |
CB_OP_ADD |
[0x00000300] Add the byte values, allowing a maximum of 255. |
CB_OP_SUBSRC |
[0x00000400] Subtract the source from the destination, allowing a minimum of 0. |
CB_OP_SUBDST |
[0x00000500] Subtract the destination from the source, allowing a minimum of 0. |
CB_OP_MUL |
[0x00000600] Multiply the byte values, allowing a maximum of 255. The result is calculated as follows: result = (source * dest) / 255. |
CB_OP_DIVSRC |
[0x00000700] Divide the destination by the source. If source > 0, then the result is calculated as follows: result = min( (dest / source) * 255, 255 ). Otherwise, if source = 0, then result = 255. |
CB_OP_DIVDST |
[0x00000800] Divide the source by the destination. If dest > 0, then the result is calculated as follows: result = min( (source / dest) * 255, 255 ). Otherwise, if dest = 0, then result = 255. |
CB_OP_AVG |
[0x00000900] Use the average of the two values. |
CB_OP_MIN |
[0x00000A00] Use the lesser of the two values. |
CB_OP_MAX |
[0x00000B00] Use the greater of the two values. |
CB_OP_ABSDIF |
[0x00000C00] Calculate the absolute difference between the two values. |
The following flags define how to treat the resulting image rectangle:
Value |
Meaning |
CB_RES_NOP |
[0x00000000] No change. |
CB_RES_NOT |
[0x00001000] Invert the color, resulting in its complement. |
CB_RES_0 |
[0x00002000] Change all bits to 0. |
CB_RES_1 |
[0x00003000] Change all bits to 1. |
The following flags define the channel of the source image rectangle:
Value |
Meaning |
CB_SRC_MASTER |
[0x00000000] perform operation on all Channels*. |
CB_SRC_RED |
[0x00010000] perform operation on Red Channel. |
CB_SRC_GREEN |
[0x00020000] perform operation on Green Channel. |
CB_SRC_BLUE |
[0x00030000] perform operation on Blue Channel. |
The following flags define the channel of the destination image rectangle:
Value |
Meaning |
CB_DST_MASTER |
[0x00000000] perform operation on all Channels*. |
CB_DST_RED |
[0x00100000] perform operation on Red Channel. |
CB_DST_GREEN |
[0x00200000] perform operation on Green Channel. |
CB_DST_BLUE |
[0x00300000] perform operation on Blue Channel. |
The following flags define the channel of the resulting image rectangle:
Value |
Meaning |
CB_RES_MASTER |
[0x00000000] perform operation on all Channels*. |
CB_RES_RED |
[0x01000000] perform operation on Red Channel. |
CB_RES_GREEN |
[0x02000000] perform operation on Green Channel. |
CB_RES_BLUE |
[0x03000000] perform operation on Blue Channel. |
The following flag determines whether to use the raw combine which combines the image data regardless of its palette or LookUpTable (LUT):
Value |
Meaning |
CB_RAWCOMBINE |
[0x04000000] perform a raw combine. |
In order to speed up widely used image processing filters in LEADTOOLS, the grayscale value (master channel) of a colored image is calculated using the following formulas:
#define CalcGrayValue(r, g, b) ((L_UCHAR)(((L_UCHAR) (((2 * (L_UINT) (r)) + (5 * (L_UINT) (g)) + (L_UINT) (b) + 4) / 8))))
#define CalcGrayValue16(r, g, b) ((L_UINT16) (((2 * (L_UINT32) (r)) + (5 * (L_UINT32) (g)) + (L_UINT32) (b) + 4) / 8))
#define CalcGrayValue32(r, g, b) ((L_UINT32) (((2 * (L_UINT32) (r)) + (5 * (L_UINT32) (g)) + (L_UINT32) (b) + 4) / 8))
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET