detect_indent_fft.hdev相关例程学习(检测凹痕)

Index:.../Applications/Surface-Inspection/detect_indent_fft.hdev
主要步骤:
 
* Optimize the fft speed for the specific image size
optimize_rft_speed (Width, Height, 'standard')
* 选取了最优rft变化速度的图像大小
* Construct a suitable filter by combining two gaussian
* filters
Sigma1 := 10.0
Sigma2 := 3.0
gen_gauss_filter (GaussFilter1, Sigma1, Sigma1, 0.0, 'none', 'rft', Width, Height)
gen_gauss_filter (GaussFilter2, Sigma2, Sigma2, 0.0, 'none', 'rft', Width, Height)
sub_image (GaussFilter1, GaussFilter2, Filter, 1, 0)
* 建立两个高斯滤波器然后又结合起来
*要搞明白究竟何为高斯滤波器 
* Process the images iteratively
NumImages := 11
for Index := 1 to NumImages by 1
    * 
    * Read an image and convert it to gray values
    read_image (Image, 'plastics/plastics_' + Index$'02')
    rgb1_to_gray (Image, Image)
    * Perform the convolution in the frequency domain
    rft_generic (Image, ImageFFT, 'to_freq', 'none', 'complex', Width)
    convol_fft (ImageFFT, Filter, ImageConvol)
    rft_generic (ImageConvol, ImageFiltered, 'from_freq', 'n', 'real', Width)
    * 各种rft变化加卷积在rft变化
    * Process the filtered image
    gray_range_rect (ImageFiltered, ImageResult, 10, 10)
*通过此步骤就找到了凹痕所在,看了这个算子的帮助文档,我就明白关键在于计算了每个mask中灰度的差,然后给一个总返回值,没有参考文献,看来是halcon自己的算法。
    min_max_gray (ImageResult, ImageResult, 0, Min, Max, Range)
    threshold (ImageResult, RegionDynThresh, max([5.55,Max * 0.8]), 255)
    connection (RegionDynThresh, ConnectedRegions)
    select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 4, 99999)
    union1 (SelectedRegions, RegionUnion)
    closing_circle (RegionUnion, RegionClosing, 10)
    connection (RegionClosing, ConnectedRegions1)
    select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 10, 99999)
    area_center (SelectedRegions1, Area, Row, Column)
    * 一系列提取算法,没有需要关注的point

学习了这个例程,明白如何有效构建高斯滤波器和利用fft变化,halcon里有rft和fft不知道内在区别,但核心都是FFT。

你可能感兴趣的:(halcon例程学习)