2.6.4.11 imgThreshold(Pro)

Menu Information

Image: Conversion: Threshold

Brief Information

Convert image to black and white using threshold

Additional Information

This feature is for OriginPro only.

Command Line Usage

1. imgThreshold low:=10 high:=200 channel:=green flt:=min oimg:=<new>;

2. imgThreshold img:=mat(1) low:=10 high:=200 channel:=green flt:=min 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.

Lower Bound low

Input

int

0

Specifies the lower bound of the range, within which the colors will be preserved.

Upper Bound high

Input

int

0

Specifies the upper bound of the range, within which the colors will be preserved. It should be greater than the Lower Bound.

Channel channel

Input

int

rgb

Specifies the color channel to be manipulated.
Option list

  • rgb:RGB
    Master channel
  • red:Red
    Red channel
  • green:Green
    Green channel
  • blue:Blue
    Blue channel
Reject Value flt

Input

int

clamp

Specifies how to define the new values for the rejected values or values outside the range defined by Lower Bound and Upper Bound.
Option list

  • min:Set to Min
    The rejected values are set to 0.
  • max:Set to Max
    The rejected values are set to the maximum value, according to the bits per pixel of the image.
  • clamp:Clamp
    The rejected values less that Lower Bound are set to 0, while the rejected values greater than Upper Bound are set to the maximum value, according to the bits per pixel of the image.
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.

Thresholding is the simplest method of image segmentation. Before the thresholding, a range that is determined by an upper bound and a lower bound is defined. Then colors of the pixels within this range will be preserved, whereas the colors of other pixels are reset.

The imgThresholding X-Function in OriginPro allows you to define the range which determines the pixel color to change by two variables, Lower Bound and Upper Bound. Additionally, you can specify how to define the new values for the rejected values (values outside the range). You can use this function to apply color adjustment or simple segmentation.

Thresholding dialog.png

Examples

In this example, we use the imgThreshold function to segment the background from the cells in the input image:

  1. When the input image is active, select Image: Conversion: Threshold. 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.
    ImgThreshold help English files image002.jpg
    A new image is created as a result.
ImgThreshold help English files image004.jpg
ImgThreshold 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_ColorThresholdBitmap() function from LEADTOOLS Main API. Please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_ColorThresholdBitmap topic.

References

LEADTOOLS Main API Help file, Version 14

Related X-Functions

imgAutoBinary, imgDynamicBinary