2.6.4.5 imgDynamicBinary(Pro)

Menu Information

Image: Conversion: Dynamic Binary

Brief Information

Convert image to binary using dynamic threshold

Additional Information

This feature is for OriginPro only.

Command Line Usage

1. imgDynamicBinary dim:=50 threshold:=10 oimg:=<new>;

2. imgDynamicBinary img:=mat(1) dim:=50 threshold:=10 oimg:=mat(2);

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input Matrix img

Input

Image

<active>

Specifies the image to be manipulated. The default input is the active image.

Dimension dim

Input

int

2

Specifies the dimension of the neighborhood, which is used when evaluating each pixel.

Threshold threshold

Input

int

0

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

<input>

Specifies the output image. By default, the output image is the same as the input image.

See the syntax here.

Description

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.

Dynamic Binary dialog.png

Examples

In this example, we use the imgDynamicBinary function to convert the grayscale image into a black and white image:

  1. When the input image is active, select Image: Conversion: Dynamic Binary. This opens the dialog of the X-Function.
  2. In the X-Function dialog, change the settings as the screenshot below and click OK to close the dialog.
    ImgDynamicBinary help English files image002.jpg
    A new image is created. We can see that it is monochromatic.
ImgDynamicBinary help English files image004.jpg
ImgDynamicBinary help English files image006.jpg
The original image
The output 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.

Algorithm

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.

Related X-Functions

imgAutoBinary, imgC2gray