halcon实现浓淡补正,中间值补正-抽取暗

代码效果

抽取前
字符
中值抽取暗
抽取后

halcon函数代码

测试图片参数 NoiseCut:=16 Gain:=1
输入ImagePart NoiseCut Gain

*获取直方图
get_domain (ImagePart, Domain)
gray_histo_range(Domain,ImagePart,0,255,256, Histo, BinSize)
area_center(Domain, NumPixels, Row, Column)
*获取中值
Threshold := NumPixels / 2
MedianValue := 0
Index := 0
while ( MedianValue< Threshold)
    Index := Index + 1
    MedianValue:=Histo[Index]+MedianValue
endwhile
MedianValue := Index
  
*中值补正

gen_image_proto(ImagePart, ImageCleared2, MedianValue)
*抽取暗
*小于中值的赋值为255
abs_diff_image(ImagePart, ImageCleared2, ImageAbsDiff1, 1)
threshold(ImageAbsDiff1, Region1, 0, 0)
paint_region(Region1, ImageAbsDiff1, ImageResult1, 255, 'fill')

*抽取暗 255- (中值-像素值-抗干扰值) * 增益
*抽取明 (像素值-中值-抗干扰值)*增益 截断
gen_image_proto(ImagePart, ImageCleared3, 255)
gen_image_proto(ImageCleared3, ImageCleared, MedianValue-NoiseCut)
sub_image(ImageCleared, ImagePart, ImageSub, Gain, 0)
sub_image(ImageCleared3, ImageSub, ImageSub22, 1, 0)
max_image(ImageResult1, ImageSub22, ImageMax)
return ()
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值