Select gray values lying within an interval.
::threshold selects the pixels from the input image whose gray values g fulfill the following condition:
MinGray <= g <= MaxGray .
All points of an image fulfilling the condition are returned as one region. If more than one gray value interval is passed (tuples for MinGray and MaxGray), one separate region is returned for each interval.
|
Image (input_object) |
image(-array) -> Hobject: HImage(Array) ( byte / direction / cyclic / int2 / int4 / real ) |
| Image to be thresholded. | |
|
Region (output_object) |
region(-array) -> Hobject * : HRegion(Array) |
| Regions with gray values lying in the specified interval. | |
|
MinGray (input_control) |
number(-array) -> HTuple.double / long |
| Lower threshold for the gray values. | |
| Default value: 128.0 | |
| Suggested values: 0.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.0 | |
| Typical range of values: 0.0 <= MinGray <= 255.0 (lin) | |
| Minimum increment: 0.01 | |
|
Recommended increment: 5.0 | |
|
MaxGray (input_control) |
number(-array) -> HTuple.double / long |
| Upper threshold for the gray values. | |
| Default value: 255.0 | |
| Suggested values: 0.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.0 | |
| Typical range of values: 0.0 <= MaxGray <= 255.0 (lin) | |
| Minimum increment: 0.01 | |
|
Recommended increment: 5.0 | |
| Restriction: MaxGray >= MinGray | |
#include <iostream.h>
#include "HalconCpp.h"
int main (int argc, char *argv[])
{
if (argc != 4)
{
cout << "Usage : " << argv[0] << " 'image' MinGray MaxGray" << endl;
return (-1);
}
HImage image (argv[1]),
Sobel;
HWindow win;
image.Display (win);
int MinGray = atoi (argv[2]);
int MaxGray = atoi (argv[3]);
Sobel = image.SobelAmp ("sum_abs", 3);
HRegionArray rand = ((image >= MinGray) & (image <= MaxGray)).Skeleton();
HRegionArray lines = rand.Connection();
HRegionArray edges = lines.SelectShape("area", "and", 10.0, 10000000.0);
edges.Display (win);
win.Click ();
return (0);
}
Let F be the area of the input region. Then the runtime complexity is O(F).
::threshold returns H_MSG_TRUE if all parameters are correct. The behavior with respect to the input images and output regions can be determined by setting the values of the flags 'no_object_result', 'empty_region_result', and 'store_empty_region' with ::set_system. If necessary, an exception is raised.
::histo_to_thresh, ::min_max_gray, ::sobel_amp, ::gauss_image, ::reduce_domain, ::fill_interlace
::connection, ::dilation1, ::erosion1, ::opening, ::closing, ::rank_region, ::shape_trans, ::skeleton
::class_2dim_sup, ::hysteresis_threshold, ::dyn_threshold
::dual_threshold, ::zero_crossing, ::background_seg, ::regiongrowing
Region processing