Perform a threshold segmentation for extracting characters.
char_threshold segments a single-channel image using an automatically determined threshold. It is assumed that the background of the image is bright and the foreground (the characters) are dark. First a histogram of the gray values in the image Image is computed in the points given by the region HistoRegion. Then the maximum in the histogram is computed (bright paper). Finally, the first gray value to the ``left'' of the maximum is located, which is at least Percent smaller than the maximum.
Image (input_object) |
image(-array) -> object : byte |
Image to be segmented. |
HistoRegion (input_object) |
region -> object |
Region in which the histogram is computed. |
Characters (output_object) |
region(-array) -> object |
Dark regions (characters). |
Percent (input_control) |
number -> real / integer |
Percentage for the gray value difference. | |
Default value: 95 | |
Suggested values: 90, 92, 95, 96, 97, 98, 99, 99.5, 100 | |
Range of values: 0.0 <= Percent <= 100.0 (lin) | |
Minimum increment: 0.1 | |
Recommended increment: 0.5 |
Threshold (output_control) |
integer(-array) -> integer |
Calculated threshold. |
#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.SetShape ("rectangle1"); w.SetColored (12); image.Display (w); HRegionArray reg = image.CharThreshold(5); HRegionArray con = reg.Connection (); cout << "Display image after BinThreshold segmentation " << endl; con.Display (w); w.Click (); return (0); }
anisotrope_diff__, median, illuminate__
connection, select_shape, select_grey__
bin_threshold, auto_threshold2, auto_threshold1, histo__, histo_gauss, threshold__