Determine the minimum and maximum gray values within regions.
The operator ::min_max_gray creates the histogram of the absolute frequencies of the gray values within Regions in the input image Image (see ::gray_histo) and calculates the number of pixels Percent corresponding to the area of the input image. Then it goes inwards on both sides of the histogram by this number of pixels and determines the smallest and the largest gray value:
e.g.:
Area = 60, percent = 5, i.e. 3 pixels
Histogram = [2,8,0,7,13,0,0,...,0,10,10,5,3,1,1]
=> Maximum = 255, Minimum = 0, Range = 255
min_max_gray returns: Maximum = 253, Minimum = 1, Range = 252
If Percent is set at 50, Min = Max
= Median. If Percent is 0 no histogram is calculated in
order to enhance the runtime.
In case of int2, int4- and real-images Percent has to be 0.
|
Regions (input_object) |
region(-array) -> Hobject: HRegion(Array) |
| Regions, the features of which are to be calculated. | |
|
Image (input_object) |
image -> Hobject: HImage ( byte / int1 / int2 / int4 / real ) |
| Gray value image. | |
|
Percent (input_control) |
number -> HTuple.double / long |
| Percentage below (above) the absolute maximum (minimum). | |
| Default value: 0 | |
| Suggested values: 0, 1, 2, 5, 7, 10, 15, 20, 30, 40, 50 | |
| Restriction: (0 <= Percent) && (Percent <= 50) | |
|
Min (output_control) |
real(-array) -> (HTuple.) double * |
| ``Minimum'' gray value. | |
|
Max (output_control) |
real(-array) -> (HTuple.) double * |
| ``Maximum'' gray value. | |
| Assertion: Max >= Min | |
|
Range (output_control) |
real(-array) -> (HTuple.) double * |
| Difference between Max and Min. | |
| Assertion: Range >= 0 | |
#include <iostream.h>
#include "HalconCpp.h"
main()
{
HImage img ("fabrik");
HWindow w;
Htuple range, max;
img.Display (w);
w.Click ();
HRegion reg = w.DrawRegion ();
HImage rdd = img.ReduceDomain (reg);
Htuple min = reg.MinMaxGray (rdd, 5, &max, &range);
HRegionArray imgseg = ((img >= min[0].I()).Connection() &
(img <= max[0].I()).Connection());
cout << "Min = " << min[0].I() << endl;
cout << "Max = " << max[0].I() << endl;
imgseg.Display (w);
w.Click ();
return(0);
}
If F is the area of the region the runtime complexity is O(F) if Percent = 0, O(F + 255) otherwise.
The operator ::min_max_gray returns the value H_MSG_TRUE if the input image has the defined gray values and the parameters are correct. The behavior in case of empty input (no input images available) is set via the operator ::set_system('no_object_result',<Result>). The behaviour in case of an empty region is set via the operator ::set_system('empty_region_result',<Result>). If necessary an exception handling is raised.
::draw_region, ::gen_circle, ::gen_ellipse, ::gen_rectangle1, ::threshold, ::regiongrowing
::gray_histo, ::scale_image, ::scale_image_max, ::learn_ndim_norm
Image filters