Segment an image using thresholds determined from its histogram.
auto_threshold2 segments a single-channel image using multiple thresholding. First the relative histogram of the gray values is determined. Then relevant minima are extracted from the histogram, which are used successively as parameters for a thresholding operation. The thresholds used are 0, 255, and all minima extracted from the histogram (after the histogram has been smoothed). For each gray value interval one region is generated. Thus, the number of regions is the number of minima + 1. The larger the value of Sigma is chosen, the less regions will be extracted. This operator is particularly suited if the regions to be extracted exhibit similar gray values (homogeneous regions).
Image (input_object) |
image(-array) -> object : byte |
Image to be segmented. |
Regions (output_object) |
region-array -> object |
Regions with gray values within the automatically determined intervals. |
Sigma (input_control) |
number -> real / integer |
Sigma for the Gaussian smoothing of the histogram. | |
Default value: 2.0 | |
Suggested values: 0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0 | |
Range of values: 0.0 <= Sigma <= 100.0 (lin) | |
Minimum increment: 0.01 | |
Recommended increment: 0.3 | |
Restriction: Sigma >= 0.0 |
#include "HCPP.H" #includeint main (int argc, char *argv[]) { if (argc != 2) { cout << "Usage : " << argv[0] << " 'image' " << endl; return (-1); } HImage image (argv[1]), med; HWindow w; w.SetDraw ("margin"); w.SetColored (12); image.Display (w); med = image.Median ("circle", 3, -3); med.Display (w); HRegionArray reg = med.AutoThreshold2 (2.0); HRegionArray con = reg.Connection (); cout << "Display image after AutoThreshold2 segmentation " << endl; con.Display (w); w.Click (); return (0); }
anisotrope_diff__, median, illuminate__
connection, select_shape, select_grey__
auto_threshold1, histo__, histo_gauss, threshold__