高斯(DoG)边缘检测器的差异

时间:2019-06-19 18:37:18

标签: matlab gaussian

我正在制作DoG边缘检测器。我必须遵循以下步骤: 1.狗 2.阈值为零 3.找到零交叉点。

到目前为止,我认为我已经成功实现了零交叉。 Matlab文档说过零的边缘函数(例如:edge(dog,'zerocross',0.025);)将应用对数边缘检测,而没有其他方法。我不确定如何使用过滤器来实现它,或者如何编写自己的过零函数。

    grayImage = imread('cl.tif');
    grayImage = rgb2gray(grayImage);
    [rows, columns, numberOfColorBands] = size(grayImage);
    % Enlarge figure to full screen.
    set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
    set(gcf,'name','DoG','numbertitle','off');

    %DoG
    gaussian1 = imgaussfilt3(grayImage, 1);
    gaussian2 = imgaussfilt3(grayImage, 9);
    dog = gaussian1 - gaussian2;

    subplot(3, 2, 3); 
    imshow(dog, []);
    title('DOG Filtered Image', 'FontSize', fontSize);
    % Let's compute and display the histogram.
    [pixelCount, grayLevels] = imhist(dog(:));
    subplot(3, 2, 4); 
    bar(grayLevels, pixelCount);
    grid on;
    title('Histogram of DOG Filtered Image', 'FontSize', fontSize);

    %Thresholding
    t = 4;
    ind_below = (dog < t);
    ind_above = (dog >= t);
    dog(ind_below) = 0;
    dog(ind_above) = 255;
    subplot(3, 2, 5);
    imshow(dog, []);
    title('Threshold', 'FontSize', fontSize);

    %Zero-crossing
    zeroCross = edge(dog, 'zerocross', 0.025);
    subplot(3, 2, 6);
    imshow(zeroCross, []);
    title('Zerocrossing', 'FontSize', fontSize);

利用程序的当前状态,我正在检测到每个小细节,噪音。目前,这就是我要获得的(https://ibb.co/HVPnnPp),最后需要得到(https://ibb.co/wJrRbk7)。原始图片(https://ibb.co/jhTLYHR)。

0 个答案:

没有答案