halcon局部阈值分割

read_image (Image1, 'alpha1')
*均值滤波
mean_image(Image1, ImageMean, 21, 21)
*局部阈值分割
dyn_threshold(Image1, ImageMean, RegionDynThresh, 15, 'dark')
read_image (Image1, 'alpha1')
*中值滤波,将文字滤除
median_image(Image1, ImageMedian, 'circle', 10.5, 'mirrored')
*局部阈值分割
dyn_threshold(Image1, ImageMedian, RegionDynThresh, 15, 'dark')
read_image (Image1, 'alpha1')
*一般是调整AbsThreshold
var_threshold(Image1, Region, 15, 15, 1.01, 15, 'dark')




read_image (Image1, 'alpha1')
median_image(Image1, ImageMedian, 'circle', 3, 'mirrored')
*局部均值和标准偏差分析阈值分割
var_threshold(ImageMedian, Region, 15, 15, 0.2, 2, 'dark')
* This example program shows the usage of var_threshold to threshold an image
* by local mean and standard deviation analysis.
* 
* With var_threshold, it's possible to select the pixels of the input Image which
* have a high local standard deviation (for a positive StdDevScale),
* or a low local standard deviation (for a negative StdDevScale)
* and are locally bright or dark, according to LightDark.
* Thus, it is possible to segment regions on inhomogeneous, noisy,
* or unevenly illuminated backgrounds.
dev_close_window ()
dev_update_off ()
* 
* Read all images in the directory 'label'
* and select all images that end with 'label_', three arbitrary characters,
* and then the string 'png'.
list_image_files ('label', 'default', [], ImageFiles)
ImageFiles1 := regexp_select(ImageFiles,'label_...png$')
* 
* Open a window to display the results.
read_image (Image, ImageFiles1[0])
get_image_size (Image, Width, Height)
dev_open_window_fit_size (0, 0, Width, Height, -1, -1, WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
* 
* Loop over all images.
for Index := 0 to |ImageFiles1| - 1 by 1
    read_image (Image, ImageFiles1[Index])
    * Threshold the image.
    var_threshold (Image, Region, 15, 15, 1.01, 40, 'dark')
    * Select regions of particular height and size.
    connection (Region, ConnectedRegions)
    select_shape (ConnectedRegions, SelectedRegions, ['height','area'], 'and', [20,100], [100,400])
    * Display the results
    dev_display (Image)
    dev_display (SelectedRegions)
    disp_continue_message (WindowHandle, 'black', 'true')
    stop ()
endfor
disp_end_of_program_message (WindowHandle, 'black', 'true')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值