Image Segmenters
There are several ways to segment pixels. The method is chosen with GetSegmentationMethod and SetSegmentationMethod.
EGrayscaleSingleThresholdSegmenter is applicable to BW8 and BW16 grayscale images and produces coded images with two layers:
- The black layer (usually Layer 0) contains unmasked pixels with a gray value below the Threshold value.
- The white layer (usually Layer 1) contains the remaining unmasked pixels, i.e. unmasked pixels having a gray value greater or equal to the Threshold value.
EasyObject provides 5 thresholding methods:
- Absolute (integer value): represents the first gray value of the white layer. Set with SetAbsoluteThreshold method and got with GetAbsoluteThreshold method.
- Relative (%): represents the fraction of image pixels that belong to the Black layer, it is a user-defined float value in range 0 to 1. Set with SetRelativeThreshold method and got with GetRelativeThreshold method.
- Minimum Residue (default): The threshold is an automatically computed value such that the quadratic difference between the source and thresholded image is minimized.
- Maximum Entropy: automatically computed value such that the entropy (i.e. the amount of information) of the resulting thresholded image is maximized.
- IsoData: automatically computed value that lies halfway between the average dark gray value (gray levels below the threshold) and average light gray values (gray levels above the threshold).
Grayscale Single Threshold with a minimum residue thresholding method is the default. Only objects whose pixels have a value that is above this threshold are encoded.
EGrayscaleDoubleThresholdSegmenter is applicable to BW8 and BW16 grayscale images and produces coded images with three layers:
- The black layer (usually Layer 0) contains unmasked pixels having a gray value below the Low Threshold value.
- The white layer (usually Layer 2) contains unmasked pixels having a gray value above or equal the High Threshold value.
- The neutral layer (usually Layer 1) contains the remaining unmasked pixels.
The Low Threshold and High Threshold are user-defined integer values, set with SetLowThreshold and SetHighThreshold methods, and got with GetLowThreshold and GetHighThreshold methods.
EColorSingleThresholdSegmenter is applicable to C24 color images; it produces coded images with two layers:
- The white layer (usually Layer 1) contains unmasked pixels that belong to the cube of the color space defined by the threshold point and the white point (255,255,255).
- The black layer(usually Layer 0) contains the remaining unmasked pixels.
The Color Threshold is a set of three user-defined integer values designating a color in the color space, set with SetThreshold method and got with GetThreshold method.
EColorRangeThresholdSegmenter is applicable to C24 color images; it produces coded images with two layers:
- The white layer(usually Layer 1) contains unmasked pixels that belong to the cube of the color space defined by the Low Threshold point and the High Threshold point.
- The black layer (usually Layer 0) contains the remaining unmasked pixels.
The Low Threshold and High Threshold are each a set of three user-defined integer values designating a color in the color space, set with SetLowThreshold and SetHighThreshold methods and got with GetLowThreshold and GetHighThreshold methods.
The following cases need a segmentation using pixel-by-pixel thresholding which gives an allowed range of values for each pixel:
- when the background is not uniform enough,
- when the illumination is not uniform across the image,
- when only differences between the image and a reference image (ideal) are to be enhanced,
The allowed range for each pixel is specified using two images: a low reference image with the minimum values allowed for each pixel, a high reference image with the maximum values. The reference images are thus the source image minus (or plus) a fixed value all over the image (assuming noise distribution is uniform and additive).
The difficulty is preparing suitable high and low reference images.
You can start from an image of the scene without defects and add security margins before comparison.
Source image
Gray-level tolerance must be provided for noise and illumination variations.
Gray-level tolerance margins
The image may have a slight shift in some direction which can be corrected by enlarging the light and dark areas using dilate and erode morphological operations. This geometric tolerance margin is roughly as large as the morphological filter size.
Geometric tolerance margins
Combining both kinds of tolerance margins gives the best results.
Combined margins
EImageRangeSegmenter and EReferenceImageSegmenter are applicable to BW8, BW16, and C24 images; and produce coded images with two layers.
The low threshold and the high threshold are defined for each pixel individually by means of two reference images of the same type as the source image: the Low Image and the High Image. The Reference Image defines the reference threshold of each pixel is individually.
- For grayscale images, the white layer (usually Layer 1) contains unmasked pixels having a gray value in a range defined by the gray value of the corresponding unmasked pixels in the Low, High or Reference Image.
- For color images, the white layer (usually Layer 1) contains unmasked pixels having a color inside the cube of the color space defined by the colors of the corresponding unmasked pixels in the Low, High or Reference Image.
- The black layer (usually Layer 0) contains the remaining unmasked pixels.
Pointers to the Low Image can be set or got using the functions associated with the type of the source image:
- BW8: SetLowImageBW8 GetLowImageBW8
- BW16: SetLowImageBW16GetLowImageBW16
- C24: SetLowImageC24GetLowImageC24
Pointers to the High Image can be set or got using the functions associated with the type of the source image:
- BW8: SetHighImageBW8GetHighImageBW8
- BW16 SetHighImageBW16GetHighImageBW16
- C24 SetHighImageC24GetHighImageC24
Pointers to the Reference Image can be set or got using the functions associated with the type of the source image:
ELabeledImageSegmenter is applicable to is applicable to BW8 and BW16 grayscale images; it produces coded images with a number of layers equal to the maximum number of gray values: 256 for BW8 images or 65536 for BW16 images. The layer n contains all the unmasked pixels having a gray value equal to n.
By default, all layers are encoded. However, it is possible to restrict the encoding to a single range of layers with SetMinLayer and SetMaxLayer functions which return the lowest and the highest values of the index range respectively.
EBinaryImageSegmenter is applicable to BW1 binary images; it produces coded images with two layers:
- Black layer (usually index 0) contains unmasked pixels with a binary value equal to zero.
- White layer (usually index 1) contains the remaining unmasked pixels, i.e. unmasked pixels with a binary value equal to one.