2
我有我從我的原始圖像概述圖像中的缺陷?
應用雙邊濾波和減去它是否有可能勾勒出玻璃缺陷如
申請霍夫後,我得到了下面的圖片下面的結果並不完美:/
我的MATLAB代碼:
im = imread('C:\Users\SUJIT\Desktop\image003.jpg');
im=rgb2gray(im);
h = fspecial('gaussian', size(im), 1.0);
g = imfilter(im, h);
im=im2double(g);
im=imadjust(im);
imgauss = imfilter(im, fspecial('gaussian',[7 7], 6),'conv');
imbi = bilateralfilter(im, [5 5], 3, 3);
imbi= im - imbi;
imshow(imbi,[]); title('Bilateral Filted Image');
I = imcrop(imbi, [30 30 450 350]);
J = imfilter(I, fspecial('gaussian', [17 17], 5), 'symmetric');
BW = edge(J, 'canny');
%# Hough Transform and show matrix
[H T R] = hough(BW);
imshow(imadjust(mat2gray(H)), [], 'XData',T, 'YData',R, ...
'InitialMagnification','fit')
xlabel('\theta (degrees)'), ylabel('\rho')
axis on, axis normal, hold on
colormap(hot), colorbar
%# detect peaks
P = houghpeaks(H, 10);
plot(T(P(:,2)), R(P(:,1)), 'gs', 'LineWidth',2);
%# detect lines and overlay on top of image
lines = houghlines(BW, T, R, P);
figure, imshow(I), hold on
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1), xy(:,2), 'g.-', 'LineWidth',2);
end
hold off
請幫我在這裏做錯了什麼?
我試過你建議的請幫忙 – 2012-03-15 16:24:07
不,你沒有。您只提取了圖像中的線條。您尚未嘗試識別玻璃窗格的區域。 – 2012-03-16 10:07:47
您可能需要先提取窗口。然後使用不同的閾值重新運行hough變換和/或邊緣檢測器。 – 2012-03-16 10:08:19