我實作了 Prewitt 邊緣檢測器并將我的輸出與 Matlab 的內置 Prewitt 邊緣檢測器進行了比較,我注意到我的輸出給出了更厚的邊緣。可能是什么原因?
input = imread('pic.png');
input = double(rgb2gray(input));
kernel_x = [-1, 0, 1; -1, 0, 1; -1, 0, 1];
kernel_y = [1, 1, 1; 0, 0, 0; -1, -1, -1];
[length, width] = size(input);
new = input;
for i = 1:length - 2
for j = 1:width - 2
Gx = sum(sum(kernel_x.*input(i:i 2, j:j 2)));
Gy = sum(sum(kernel_y.*input(i:i 2, j:j 2)));
new(i 1, j 1) = sqrt(Gx.^2 Gy.^2);
end
end
new = uint8(new);
% binarizing image and setting threshold
edge = imbinarize(edge, 100); % final output from implementation
我使用的內置函式是edge(input, 'Prewitt')
我的實作與內置運算子的輸出:

這可能是什么原因?
我也嘗試更改閾值,但仍然沒有運氣。
uj5u.com熱心網友回復:
檔案中沒有明確說明,但對于 Sobel、Prewitt 和 Roberts 方法,edge應用了細化。有一個可選的輸入引數'nothinning',它跳過細化步驟。不幸的是,這是檔案中唯一表明此步驟正在發生的地方。
如果您擁有使用 的影像處理工具箱,則可以應用細化bwmorph(bw,'thin')。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/350372.html
