2.6.4.3 imgBinary
Contents
Menu Information
Image: Conversion: Binary
Brief Information
Convert image to binary
Command Line Usage
1. imgBinary t1:=30 t2:=160 c:=red oimg:=mat(2);
2. imgBinary img:=[Mbook1]Msheet1!Mat(1) oimg:=<new>;
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 |
|
Specifies the image to be manipulated. The default input is the active image. |
| Low | t1 |
Input int |
|
Specifies the lowest intensity to be detected. Possible values range from 0 to 255. |
| High | t2 |
Input int |
|
Specifies the highest intensity to be detected. Possible values range from 0 to 255. |
| Channel | c |
Input int |
|
Specifies the color channel to process.
|
| 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. |
Description
This X-Function converts the input image into a binary image by separating the image pixels using thresholds. You can define the thresholds with the variables, Low and High. Any pixels with intensity lower than the value of the Low variable and any pixels with intensity higher than the value of the High variable will be set to 0, which represents the black color. Other pixels will be set to the white color.
Examples
In this example, we use the imgBinary function to convert the input image into a binary one:
- When the input image is active, select Image: Conversion: Binary. This opens the dialog of the X-Function.
- In the X-Function dialog, change the settings as the screenshot below and click OK to close the dialog.

A new image is created. We can see that it is monochromatic.
![]() |
![]() |
|
|
|
Algorithm
The computation uses L_IntensityDetectBitmap() function from LEADTOOLS Main API. Please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_IntensityDetectBitmap topic.
References
LEADTOOLS Main API Help file, Version 14

