2.6.4.3 imgBinary

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

<active>

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

RGB

Specifies the color channel to process.
Option list

  • rgb:RGB
    RGB channels.
  • red:Red
    Red channel only.
  • green:Green
    Green channel only.
  • blue:Blue
    Blue channel only.
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

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:

  1. When the input image is active, select Image: Conversion: 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.
    ImgBinary help English files image002.jpg
    A new image is created. We can see that it is monochromatic.
ImgBinary help English files image004.jpg
ImgBinary help English files image006.jpg
The original image
The output image


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

Related X-Functions

imgAutoBinary, imgDynamicBinary, imgC2gray