Halcon区域分割

简介:

               区域分割,可用于分割目标区域。

 

介绍: 

trans_from_rgb (将图像从RGB颜色空间转换为任意颜色空间)
ImageRed (input_object)  Input image (red channel).通道R图像
ImageGreen (input_object)  Input image (green channel).通道G图像
ImageBlue (input_object) Input image (blue channel).通道B图像
ImageResult1 (output_object)Color-transformed output image (channel 1).输出的结果1
ImageResult2 (output_object)  Color-transformed output image (channel 1).输出的结果2
ImageResult3 (output_object)  Color-transformed output image (channel 1).输出的结果3
ColorSpace (input_control)

Color space of the output image.
Default value: 'hsv'
List of values: 'argyb', 'cielab', 'cielchab', 'cielchuv', 'cieluv', 'ciexyz', 'ciexyz2', 'ciexyz3', 'ciexyz4', 'hls', 'hsi', 'hsv', 'i1i2i3', 'ihs', 'lms', 'yiq', 'yuv'
List of values (for compute devices): 'cielab', 'cielchab', 'cieluv', 'cielchuv', 'hsv', 'hsi'

hsv

  Min := min([R, G, B])
  Max := max([R, G, B])
  V := Max
  if (Max == Min)
     S := 0
     H := 0
  else
     S := (Max - Min) / Max
     if (R == Max)
        H := ((G - B) / (Max - Min)) * rad(60)
     elseif (G == Max)
        H := (2 + (B - R) / (Max - Min)) * rad(60)
     elseif (B == Max)
        H := (4 + (R - G) / (Max - Min)) * rad(60)
     endif
  endif

输出图像的颜色空间
auto_threshold(自动阈值)
Image (input_object)  Input image.图像
Regions (output_object) Regions with gray values within the automatically determined intervals.输出的区域
Sigma (input_control)  Sigma for the Gaussian smoothing of the histogram.
Default value: 2.0
Suggested values: 0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0
Typical range of values: 0.0 ≤ Sigma ≤ 100.0 (lin)
Minimum increment: 0.01
Recommended increment: 0.3
Restriction: Sigma >= 0.0
高斯平滑的数值
threshold(全局阈值)
Image (input_object) Input image.图像
Region (output_object)Segmented region.输出的分割区域
MinGray (input_control)  Lower threshold for the gray values.
Default value: 128.0
Suggested values: 0.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.0
灰度值最小的阈值
MaxGray (input_control)  Upper threshold for the gray values.
Default value: 255.0
Suggested values: 0.0, 10.0, 30.0, 64.0, 128.0, 200.0, 220.0, 255.0
Restriction: MaxGray >= MinGray
灰度值最大的阈值

 

使用:

  1. 彩色图像要转成灰色图像。
  2. 自动阈值提取目标区域。也可以通过其它阈值函数(threshold等)提取。
  3. 根据特征进行区域分割,提取目标区域。
read_image (Image, 'E:/照片/RGB')
decompose3 (Image, Image1, Image2, Image3)
trans_from_rgb (Image1, Image2, Image3, ImageResult1, ImageResult2, ImageResult3, 'hsv')
*自动阈值
auto_threshold (ImageResult3, Regions, 2)
*全局阈值
*threshold (ImageResult3, Regions, 128, 255)
connection (Regions, ConnectedRegions)
*特征选择,面积
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 100, 1500)
count_obj (SelectedRegions, Number)
for Index := 1 to Number by 1
    select_obj (SelectedRegions, ObjectSelected, Index)
    area_center (ObjectSelected, Area1, Row1, Column1)  
    disp_message (3600, Area1, 'image', Row1, Column1, 'black', 'true')
endfor

 

RGB

 

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值