read_image (Image1, 'Clip')
gray_histo(Image1, Image1, AbsoluteHisto, RelativeHisto)
gen_region_histo(Region, AbsoluteHisto, 255, 255, 1)
*8是通过实验出来的,默认值2时MinThresh, MaxThresh值比较多不合适
histo_to_thresh(AbsoluteHisto,8, MinThresh, MaxThresh)
threshold(Image1, Region1, MinThresh, MaxThresh)
read_image (Image1, 'Clip')
*产生灰度直方图
gray_histo(Image1, Image1, AbsoluteHisto, RelativeHisto)
*根据灰度直方图产生灰度直方图区域,便于可视化
gen_region_histo(Region, AbsoluteHisto, 255, 255, 1)
*计算灰度值阈值元组
histo_to_thresh(AbsoluteHisto, 10, MinThresh, MaxThresh)
*期望目标灰度值
TargetGray:=23
*根据期望目标灰度值自动选择阈值
MinGray:=255
MaxGray:=0
*最小阈值元组从右往左遍历,第一个小于或等于期望目标灰度值的元素作为目标的最小阈值
for i:=|MinThresh|-1 to 0 by -1
if(MinThresh[i]<=TargetGray)
MinGray:=MinThresh[i]
break
endif
endfor
*最大阈值元组从左往右2遍历,第一个大于或等于期望目标灰度值的元素作为目标的最大阈值
for i:=0 to |MaxThresh|-1 by 1
if(MaxThresh[i]>=TargetGray)
MaxGray:=MaxThresh[i]
break
endif
endfor
threshold(Image1, Region, MinGray, MaxGray)
read_image (Image1, 'Clip')
bin_threshold(Image1, Region)
read_image (Image1, 'fabrik')
median_image(Image1, ImageMedian, 'circle', 3, 'mirrored')
auto_threshold(ImageMedian, Regions, 2)