Halcon算子之min_max_gray
* 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)
此算子用于提取 Regions 所在区域图像的最大与最小灰度值
如果percent参数设置为5,那么图像中灰度值最大和最小的5%的像素不参与最大最小灰度值的计算
先统计区域内图像的灰度直方图,即在0-255灰度值范围内图像像素个数的分布频率图。
区域面积乘以***percent***
得到一个数,设为 a,然后用 a
分别从0灰度值和255灰度值处向里截取a
个像素点。
然后在剩下的像素点
中取最小最大灰度值
Name
min_max_gray — Determine the minimum and maximum gray values within regions.
Signature
min_max_gray(Regions, Image : : Percent : Min, Max, Range)
Description
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
For images of type int4, int8, and real, the above calculation is not performed via histograms, but using a rank selection algorithm. If Percent is set to 50, Min = Max = Median. If Percent is 0 no histogram is calculated in order to enhance the runtime.
Attention
Note that the operator min_max_gray only considers the given Regions and ignores any previously set domain of the input image Image.