Skip to content

min_max_grayMinMaxGrayMinMaxGraymin_max_graymin_max_grayπŸ”—

Short descriptionπŸ”—

min_max_grayMinMaxGrayMinMaxGraymin_max_graymin_max_gray β€” Determine the minimum and maximum gray values within regions.

SignatureπŸ”—

min_max_gray( region Regions, image Image, number Percent, out real Min, out real Max, out real Range )void MinMaxGray( const HObject& Regions, const HObject& Image, const HTuple& Percent, HTuple* Min, HTuple* Max, HTuple* Range )static void HOperatorSet.MinMaxGray( HObject regions, HObject image, HTuple percent, out HTuple min, out HTuple max, out HTuple range )def min_max_gray( regions: HObject, image: HObject, percent: Union[int, float] ) -> Tuple[Sequence[float], Sequence[float], Sequence[float]]

def min_max_gray_s( regions: HObject, image: HObject, percent: Union[int, float] ) -> Tuple[float, float, float]Herror min_max_gray( const Hobject Regions, const Hobject Image, double Percent, double* Min, double* Max, double* Range )

Herror T_min_max_gray( const Hobject Regions, const Hobject Image, const Htuple Percent, Htuple* Min, Htuple* Max, Htuple* Range )

void HImage::MinMaxGray( const HRegion& Regions, const HTuple& Percent, HTuple* Min, HTuple* Max, HTuple* Range ) const

void HImage::MinMaxGray( const HRegion& Regions, double Percent, double* Min, double* Max, double* Range ) const

void HRegion::MinMaxGray( const HImage& Image, const HTuple& Percent, HTuple* Min, HTuple* Max, HTuple* Range ) const

void HRegion::MinMaxGray( const HImage& Image, double Percent, double* Min, double* Max, double* Range ) const

void HImage.MinMaxGray( HRegion regions, HTuple percent, out HTuple min, out HTuple max, out HTuple range )

void HImage.MinMaxGray( HRegion regions, double percent, out double min, out double max, out double range )

void HRegion.MinMaxGray( HImage image, HTuple percent, out HTuple min, out HTuple max, out HTuple range )

void HRegion.MinMaxGray( HImage image, double percent, out double min, out double max, out double range )

DescriptionπŸ”—

The operator min_max_grayMinMaxGray creates the histogram of the absolute frequencies of the gray values within Regionsregionsregions in the input image Imageimageimage (see gray_histoGrayHisto) and calculates the number of pixels Percentpercentpercent 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:

For images of type int4, int8, and real, the above calculation is not performed via histograms, but using a rank selection algorithm. If Percentpercentpercent is set to 5050, Minminmin = Maxmaxmax = Median. If Percentpercentpercent is 00 no histogram is calculated in order to enhance the runtime.

AttentionπŸ”—

Note that the operator min_max_grayMinMaxGray only considers the given Regionsregionsregions and ignores any previously set domain of the input image Imageimageimage.

Execution informationπŸ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

ParametersπŸ”—

Regionsregionsregions (input_object) region(-array) β†’ objectHObjectHRegionHObjectHobject

Regions, the features of which are to be calculated.

Imageimageimage (input_object) singlechannelimage β†’ object (byte / direction / cyclic / int1 / int2 / uint2 / int4 / int8 / real)HObject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / int8 / real)HImage (byte / direction / cyclic / int1 / int2 / uint2 / int4 / int8 / real)HObject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / int8 / real)Hobject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / int8 / real)

Gray value image.

Percentpercentpercent (input_control) number β†’ (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[int, float]Htuple (double / Hlong)

Percentage below (above) the absolute maximum (minimum).

Default: 00
Suggested values: 0, 1, 2, 5, 7, 10, 15, 20, 30, 40, 500, 1, 2, 5, 7, 10, 15, 20, 30, 40, 50
Restriction: 0 <= Percent && Percent <= 50

Minminmin (output_control) real(-array) β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

β€œMinimum” gray value.

Maxmaxmax (output_control) real(-array) β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

β€œMaximum” gray value.

Assertion: Max >= Min

Rangerangerange (output_control) real(-array) β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Difference between Max and Min.

Assertion: Range >= 0

ExampleπŸ”—

(HDevelop)

* Threshold segmentation with training region:
read_image(Image,'fabrik')
draw_region(Region,WindowHandle)
min_max_gray(Region,Image,5,Min,Max,Range)
threshold(Image,SegmentedRegion,Min,Max)
dev_display(SegmentedRegion)
(C)
/* Threshold segmentation with training region: */
read_image(&Image,"fabrik")\;
draw_region(&Region,WindowHandle)\;
min_max_gray(Region,Image,5.0,&Min,&Max,NULL)\;
threshold(Image,&SegmentedRegion,Min,Max)\;
disp_region(SegmentedRegion,WindowHandle)\;
(C++)
#include "HalconCpp.h"
using namespace Halcon\;
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std\;
#endif

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)\;
}

ResultπŸ”—

The operator min_max_grayMinMaxGray returns the value 2 (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 behavior in case of an empty region is set via the operator set_system(::'empty_region_result',<Result>:). If necessary an exception is raised.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

draw_regionDrawRegion, gen_circleGenCircle, gen_ellipseGenEllipse, gen_rectangle1GenRectangle1, thresholdThreshold, regiongrowingRegiongrowing

Possible successors

thresholdThreshold

Alternatives

select_graySelectGray, intensityIntensity

See also

gray_histoGrayHisto, scale_imageScaleImage, scale_image_maxScaleImageMax, learn_ndim_normLearnNdimNorm

ModuleπŸ”—

Foundation