小哥哥小姐姐觉得有用点个赞呗!
HALCON示例程序texture.hdev检测树木
示例程序源码(加注释)
- 关于显示类函数解释
dev_close_window ()
Interactive := 0
dev_close_window ()
read_image (MreutHill, ‘mreut_y’)
get_image_size (MreutHill, Width, Height)
dev_open_window (0, 0, Width, Height, ‘black’, WindowHandle) - texture_laws - 使用Laws纹理过滤器过滤图像。
- texture_laws(图像:滤波后图像:滤波模式,动态转移灰度值,滤波掩膜大小 ?
texture_laws (MreutHill, SS, ‘ss’, 0, 5)
texture_laws (MreutHill, EE, ‘ee’, 2, 5) - 使用矩形掩膜进行中值滤波
median_separate (SS, SSMed, 25, 25, ‘mirrored’)
median_separate (EE, EEMed, 25, 25, ‘mirrored’)
dev_display (MreutHill)
if (Interactive)
draw_region (TestReg, WindowHandle)
else
gen_rectangle1 (TestReg, 376, 221, 466, 246)
endif - histo_2dim - 计算双维度灰度值图像的直方图
histo_2dim (TestReg, SSMed, EEMed, Histo2Dim)
threshold (Histo2Dim, RegionFeat, 3, 1000000)
fill_up (RegionFeat, RegionFillUpFeat)
opening_circle (RegionFillUpFeat, FeatOpen, 1.5)
dilation_circle (FeatOpen, FeatureSpace, 1.5) - 使用二维像素分类对图像进行分割
class_2dim_sup (SSMed, EEMed, FeatureSpace, RegionClass)
opening_circle (RegionClass, ResultClass2, 3.5)
dev_set_color (‘red’)
dev_set_draw (‘margin’)
dev_display (MreutHill)
dev_display (ResultClass2)
disp_continue_message (WindowHandle, ‘black’, ‘true’)
stop ()
threshold (SSMed, RegionThre, 35, 255)
connection (RegionThre, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, ‘area’, ‘and’, 150.000000, 99999.000000)
closing_circle (SelectedRegions, ResultClass1, 3.5)
dev_display (MreutHill)
dev_display (ResultClass1)
处理思路
这个例子是主要讲解了histo_2dim 、class_2dim_sup 搭配使用灰度直方图进行图像分割。
后记
大家有什么问题可以向我提问哈,我看到了第一时间回复,希望在学习的路上多多结交良师益友。