# 2.6.4.3 imgBinary

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>; 

## 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.

A new image is created. We can see that it is monochromatic.
 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