1、利用二维像素分类方法对彩色图像进行分割
read_image (Image, 'ic') dev_close_window () get_image_size (Image, Width, Height) dev_open_window (0, 0, Width, Height, 'white', WindowID) * 转换一个三通道图像成三个图像 decompose3 (Image, Red, Green, Blue) dev_display (Red) dev_set_color ('red') draw_region (Pattern, WindowID) * 计算双通道灰度值图像的直方图 histo_2dim (Pattern, Red, Blue, Histo2Dim) threshold (Histo2Dim, Features, 1, 255) * 使用循环结构元素关闭区域 closing_circle (Features, FeaturesClosed, 11.5) dev_set_draw ('fill') dev_set_part (0, 0, 511, 511) dev_display (Red) class_2dim_sup (Red, Blue, FeaturesClosed, RegionClass2Dim)
算法流程:手绘一个感兴趣区域,然后根据灰度值关系,找到另一幅图像中的相似区域
2、使用超球体分类像素
read_image (Image, 'ic') gen_rectangle1 (Region, 360, 264, 371, 301) gen_empty_region (EmptyRegion) learn_ndim_norm (Region, EmptyRegion, Image, 'euclid', 10, 0.01, Radius, Center, Quality) dev_set_color ('blue') class_ndim_norm (Image, Regions, 'euclid', 'multiple', Radius, Center) dev_display (Image) dev_display (Regions)
核心算子:
learn_ndim_norm(Foreground, Background, Image : : Metric, Distance, MinNumberPercent : Radius, Center, Quality) — 从区域前景和多通道图像中对应的灰度值生成分类聚类
参数Distance决定了簇的最大距离半径。它描述了两个集群中心之间的最小距离。在参数距离较小的情况下,超立方体或超球体可以很好地逼近特征空间。
class_ndim_norm(MultiChannelImage : Regions : Metric, SingleMultiple, Radius, Center : ) — 使用超球体或超立方体分类像素。
class_ndim_norm对MultiChannelImage中给出的多通道图像的像素进行分类。结果以区域的形式返回,每个分类对象返回一个区域。参数Radius, Center必须设置为与learn_ndim_norm中使用的值相同。参数SingleMultiple确定为每个集群生成一个区域(‘single’)还是多个区域(‘multiple’)。半径分别决定了簇的半径或半边长。中心决定了它们的中心。
结果显示:
首先生成一个感兴趣区域
找到测试图中相似区域
3、采用区域网格方式对图像进行分割
read_image (Image1, 'C:/Users/Administrator/Desktop/1.jpg') decompose3 (Image1, R, G, B) trans_from_rgb (R, G, B, H, S, V, 'hsv') dev_display (G) get_image_size (G, Width, Height) *生成网格区域 gen_grid_region (RegionGrid, 10, 10, 'lines', Width, Width) reduce_domain (G, RegionGrid, ImageReduced) threshold (ImageReduced, Region, 0, 150) *blob分析提取硬币 closing_circle (Region, RegionClosing1, 10) connection (RegionClosing1, ConnectedRegions3) select_shape (ConnectedRegions3, SelectedRegions2, ['roundness','area'], 'and', [0.5822,2634.23], [1,20000]) closing_circle (SelectedRegions2, RegionClosing, 10) opening_circle (RegionClosing, RegionOpening1, 20) shape_trans (RegionOpening1, RegionTrans, 'outer_circle') union1 (RegionTrans, RegionUnion) reduce_domain (G, RegionUnion, ImageReduced1) dev_display (ImageReduced1)
戳戳小手帮忙点个免费的赞和关注吧,嘿嘿。 |