Image: Conversion: Dynamic Binary
Convert image to binary using dynamic threshold
This feature is for OriginPro only.
1. imgDynamicBinary dim:=50 threshold:=10 oimg:=<new>;
2. imgDynamicBinary img:=mat(1) dim:=50 threshold:=10 oimg:=mat(2);
Please refer to the page for additional option switches when accessing the x-function from script
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
Input Matrix | img |
Input Image |
|
Specifies the image to be manipulated. The default input is the active image. |
Dimension | dim |
Input int |
|
Specifies the dimension of the neighborhood, which is used when evaluating each pixel. |
Threshold | threshold |
Input int |
|
Specifies the local contrast threshold. If the contrast of the area surrounding the pixel is below this threshold, the pixel is converted to black or white using a global pre-calculated threshold. If the contrast of the area surrounding the pixel is higher than this threshold, the local threshold value is calculated and used. |
Output Image | oimg |
Output Image |
|
Specifies the output image. By default, the output image is the same as the input image. See the syntax here. |
Color Resolution Conversions tools include Color to B/W (Dynamic Binary), Thresholding, and Gray Colorize. The first two are Pro only.
The imgDynamicBinary function converts a specified image into a black and white image without changing its bits per pixel, using a local threshold value for each pixel of the image.
Each pixel is compared to a dynamically-calculated threshold that is determined by its adjacent pixels. If the intensity of the pixel is higher (that is, the pixel is brighter) than the dynamic threshold, the pixel will be set to white. If the intensity of the pixel is lower (that is, the pixel is darker) than the dynamic threshold, the pixel will be set to black.
This function allows you to specify the dimension of the neighborhood, which is used when evaluating each pixel, and specifies the local contrast threshold.
In this example, we use the imgDynamicBinary function to convert the grayscale image into a black and white image:
Note: OriginPro includes the ability to automatically recalculate the analysis results of the Color Resolution Conversions operation any time you change the parameters or update your source data. In addition, the settings for this analysis routine can be saved to an analysis theme for use later with similar data.
The computation uses L_DynamicBinaryBitmap () function from LEADTOOLS Main API. Please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_DynamicBinaryBitmap topic.