2012-03-15 35 views
2

我有我從我的原始圖像概述圖像中的缺陷?

應用雙邊濾波和減去它是否有可能勾勒出玻璃缺陷如

enter image description here

申請霍夫後,我得到了下面的圖片下面的結果並不完美:/

enter image description here

我的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 

請幫我在這裏做錯了什麼?

回答

2

根據只有一張圖片而沒有其他信息給出一般答案有點難,但我可以根據您的示例圖片給出具體答案。

假設你想要找到的是圖像中間的垂直模糊線,這是我的方法。我不會詳細介紹具體的實施細節,但只是介紹我將如何實施。

  1. 找到窗戶。這有多種方法。有些想法要麼找到角落,要麼找到矩形結構本身。霍夫變換是一種可能的工具。

  2. 對於每個窗口,檢查是否有垂直結構。

+0

我試過你建議的請幫忙 – 2012-03-15 16:24:07

+0

不,你沒有。您只提取了圖像中的線條。您尚未嘗試識別玻璃窗格的區域。 – 2012-03-16 10:07:47

+0

您可能需要先提取窗口。然後使用不同的閾值重新運行hough變換和/或邊緣檢測器。 – 2012-03-16 10:08:19