You are here: Start » FIL.NET » FIL.ThresholdImage
Transforms each pixel value to maximum or minimum depending on whether they belong to the specified range.
Namespace: | FilNet |
---|---|
Assembly: | FIL.NET.dll |
Syntax
public static void ThresholdImage ( FilNet.Image inImage, NullableRef<FilNet.Region> inRoi, float? inMinValue, float? inMaxValue, float inFuzziness, FilNet.Image outMonoImage )
Parameters
Name | Type | Range | Default | Description | |
---|---|---|---|---|---|
![]() | inImage | FilNet.Image | Input image. | ||
![]() | inRoi | FilNet.NullableRef<FilNet.Region> | Region of interest. Default value: ftl::NIL. | ||
![]() | inMinValue | float? | 128.0f | Minimum value of a pixel that is considered foreground (Auto = -INF). Default value: 128.0f. | |
![]() | inMaxValue | float? | Maximum value of a pixel that is considered foreground (Auto = +INF). Default value: ftl::NIL. | ||
![]() | inFuzziness | float | <0.0f, INF> | 0.0f | A tolerance for inMin/MaxValue that results in intermediate output values. Default value: 0.0f. |
![]() | outMonoImage | FilNet.Image |
Description
The operation transforms each pixel value to the maximum or minimum level thus creating binary image. The result of the transformation depends on the pixel intensity:
- Pixel values in range (inMinValue, inMaxValue) are transformed to the maximum level.
- Other pixel values are transformed to the minimum level.
If any of the parameters inMinValue, inMaxValue is not set, it is assumed to be, accordingly, -infinity or infinity.
Parameter inFuzziness (set to 0 by default) allows to perform fuzzy thresholding which linearly interpolates those pixel values that differ by at most inFuzziness from the values inMinValue, inMaxValue; thus creating smooth transition between minimum and maximum values in the resulting image (see Remarks section).
In the multichannel images the operation uses an average of channel values in each pixel, thus the resulting image is always monochromatic.
Examples
![]() |
![]() |
ThresholdImage performed on the sample image with inMinValue = 80.0, inMaxValue = auto, inFuzziness = 0.0.
![]() |
![]() |
ThresholdImage performed on the sample image with inMinValue = 80.0, inMaxValue = auto, inFuzziness = 2.5.
Having a form with PictureBox, two TrackBar controls, and some image (e.g. reusable image loaded on an application start,
or grabbed from a camera)
thresholding results may be displayed in a picture box with a following UpdateThresholdedImage
method assigned
to the track bars' ValueChanged events. Following example is a part of a bigger Basic Thresholding Example
// In the form designer trackBar1 Maximum property is set to 255 // so the thresholding may be performed in the full range. // each time the threshold is changed, the same image buffer will be used so there is no need to disposing it if (thresholdedImage == null) thresholdedImage = new Image(); // get thresholded image with FIL function. FIL.ThresholdImage(lenaMonoImage, null, null, trackBar1.Value, 1.0f, thresholdedImage); //dispose previously displayed image if (pictureBox1.Image != null) pictureBox1.Image.Dispose(); //create .NET Bitmap that can be displayed by the PictureBox control pictureBox1.Image = thresholdedImage.CreateBitmap();
Remarks
Hardware Acceleration
This operation is optimized for SSE2 technology for pixels of types: 1xUINT8 (for inFuzziness = 0), 3xUINT8 (for inFuzziness = 0).
This operation is optimized for AVX2 technology for pixels of types: 1xUINT8 (for inFuzziness = 0), 3xUINT8 (for inFuzziness = 0).
This operation supports automatic parallelization for multicore and multiprocessor systems.
Hardware acceleration settings may be manipulated with Settings class.
Errors
List of possible exceptions:
Error type | Description |
---|---|
DomainError | Region exceeds an input image in ThresholdImage. |