[FlagsAttribute()]
public enum ApplyMathematicalLogicCommandFlags
Value | Member | Description |
---|---|---|
0x00000000 | Master | All channels. |
0x00000000 | ValueDoNothing | No change. |
0x00000000 | OperationAnd | Combine each pixel component value and the Factor property using a bitwise AND (&). (pixel = pixel & Factor) |
0x00000000 | ResultDoNothing | No change. |
0x00000001 | Red | Red channel only. |
0x00000002 | Green | Green channel only. |
0x00000003 | Blue | Blue channel only. |
0x00000010 | ValueNot | Invert the color, resulting in its complement. |
0x00000020 | ValueZero | Change all bits to 0. |
0x00000030 | ValueOne | Change all bits to 1. |
0x00000100 | OperationOr | Combine each pixel component value and the Factor property using a bitwise OR ( ¦ ). (pixel = pixel | Factor) |
0x00000200 | OperationXor | Combine each pixel component value and the Factor property using a bitwise XOR (^). (pixel = pixel ^ Factor) |
0x00000300 | OperationAdd | Add pixel component value to the Factor property, clamping the result to the maximum allowed pixel value. (pixel = min(pixel + Factor, MaximumPixelValue) ) |
0x00000400 | OperationSubtractFactor | Subtract each pixel component value from the Factor property, clamping the result to the allowed pixel range. (pixel = min(max(Factor - pixel, MinimumPixelValue), MaximumPixelValue) ) |
0x00000500 | OperationSubtractValue | Subtract the Factor property from each pixel component value, clamping the result to the allowed pixel range. (pixel = min(max(pixel - Factor), MinimumPixelValue, MaximumPixelValue) ) |
0x00000600 | OperationAbsoluteDifference | Calculate the Absolute difference between the Factor property and each pixel component value. (pixel = abs(pixel - Factor)) |
0x00000700 | OperationMultiply | Multiply each pixel component value by Factor/100. (pixel = pixel * Factor / 100) |
0x00000800 | OperationDivisionByFactor | Divide each pixel component value by Factor/100. An error will be returned if Factor = 0. (pixel = pixel * 100 / Factor) |
0x00000900 | OperationDivisionByValue | Divide the Factor property by each pixel value. If the pixel value is 0, the result is set to the maximum allowed pixel value. (pixel = pixel ? min(Factor / pixel, MaximumPixelValue) : MaximumPixelValue) |
0x00000A00 | OperationAverage | Use the average of the each pixel component value and the Factor property. (pixel = (pixel+Factor) / 2). |
0x00000B00 | OperationMinimum | Use the lesser of the pixel component values and the Factor property. (pixel = min(pixel, Factor) ) |
0x00000C00 | OperationMaximum | Use the greater of the pixel component values and the Factor property. (pixel = max(pixel, Factor) ) |
0x00001000 | ResultNot | Invert the color, resulting in its complement. |
0x00002000 | ResultZero | Change all bits to 0. |
0x00003000 | ResultOne | Change all bits to 1. |
These flags have a FlagsAttribute attribute that allows a bitwise combination of its member values. You can use a bitwise OR ( ¦ ) to specify one flag from each group.
Group | Flags |
Flags that indicate the channel that will be used | Master, Red, Green, Blue |
Flags that indicate how to treat the color value | ValueDoNothing, ValueNot, ValueZero, ValueOne |
Flags that indicate the mathematical operation to use | OperationAnd, ValueNot, ValueZero, ValueOne, OperationAnd, OperationOr, OperationXor, OperationAdd, OperationSubtractFactor, OperationSubtractValue, OperationAbsoluteDifference, OperationMultiply, OperationDivisionByFactor, OperationDivisionByValue, OperationAverage, OperationMinimum, OperationMaximum |
Flags that indicate how to treat the output value | ResultDoNothing, ResultNot, ResultZero, ResultOne |
If the Flags property is set to OperationSubtract, OperationDifference, or OperationAverage, the valid range of the Factor property is from 2 * MinimumPixelValue to 2 * MaximumPixelValue.
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))