zoukankan      html  css  js  c++  java
  • Compactness问题

    今天偶然在论坛讨论在halcon下紧密度的问题,现在总结一下

    Calculation:

    If L is the length of the contour (see contlength) and F the area of the region the shape factor C is defined as:

    C = L^2 / (4 F pi)) 

    在halcon中画个圆测出来的紧密度不为1,按道理讲圆的紧密度为1才对,后来了解到,在halcon中画的圆并不是绝对意义上的圆,因为在halcon里面它是以像素为单位的,所以并不是严格意义上的圆。所以应该是略大于1,小于1.5.

    经验:对于有孔的圆,一般的紧密度大概在1.5--2.5之前,细小长条则大于2.5(一般,不绝对)

    经过测试发现:

          在halcon中,当半径为10的情况下,其compactness为1.04,而半径<10,其compactness基本上就略等于1啦。

    针对这个算子有个例程(选出圆形的region):

    dev_close_window()
    read_image (Image, '1.jpg')
    get_image_size(Image,Widht,Height)
    dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle1)
    rgb1_to_gray (Image, GrayImage)
    threshold (GrayImage, Region, 50, 255)
    *union1 (Region, RegionUnion)
    connection (Region, ConnectedRegions)
    fill_up (ConnectedRegions, RegionFillUp)
    *select_obj(RegionFillUp, ObjectSelected,2)
    *disp_region(ObjectSelected,WindowHandle1)
    *dev_display(ObjectSelected)
    select_shape (RegionFillUp, SelectedRegions, 'compactness', 'and', 1, 5)
    View Code
  • 相关阅读:
    P2351 [SDOI2012]吊灯
    洛谷P1450 [HAOI2008]硬币购物 背包+容斥
    P5110 块速递推-光速幂、斐波那契数列通项
    AT2304 Cleaning
    CSP-S 2020
    CF487E Tourists
    P4334 [COI2007] Policija
    动态逆序对专练
    CF437D The Child and Zoo
    CF1032G Chattering
  • 原文地址:https://www.cnblogs.com/nanyangzp/p/3418591.html
Copyright © 2011-2022 走看看