2016-12-27 302 views
0

我試圖用「一」過濾作用和「CONV 2」來計算兩個矩陣的卷積(原始圖像實現一個簡單的低通濾波器和過濾器),這是過濾的圖像我想要得到的,但imshow(filteredImage的結果)是一個空的白色圖像,而不是一個過濾圖像。MATLAB:應用低通濾波器,圖像

我已經檢查了過濾的圖像的矩陣的計算方法,它是一個256×256雙,但我不知道爲什麼顯示不正確的原因吧。

I = imread('cameraman.tif'); 

filteredImage = conv2(double(I), double(ones(3,3)), 'same'); 

figure; subplot(1,2,1); imshow(filteredImage);title('filtered'); 
    subplot(1,2,2); imshow(I); title('original'); 

編輯: 我也曾嘗試將其轉換成計算卷積,因爲它是超過1日前首次加倍,但它並沒有給出一個低通濾波器的效果,但圖像的對比度得到了,而不是上升。

I = imread('cameraman.tif'); 
I1 = im2double(I); 
filteredImage = conv2(I1, ones(2,2), 'same'); 

figure; subplot(1,2,1); imshow(filteredImage);title('filtered'); 
    subplot(1,2,2); imshow(I1); title('original'); 
+0

圖像被預期具有值範圍從'0'到'1' double'類型'的。你的'filteredImage'可能超過了這個。 – beaker

+0

@beaker是的,它超過了,但我已經使用「im2double」將它轉換爲第一個,但它太白而不是變得模糊 –

+0

好吧,現在您已經達到第二個問題。 'filteredImage'中的數值範圍是多少?在你編輯的代碼中,我願意打賭他們在'0'和'4'之間。 – beaker

回答

0

下述溶液具有固定的範圍內的問題,給出了有關特定類型的低通濾波器中的哪一個的平均過濾接,其他的解決方案:

Img1 = imread('cameraman.tif'); 
Im=im2double(Img1); 
filteredImage = conv2(Im, ones(3,3)); 
figure; subplot(1,2,1); imshow(filteredImage, []);title('filtered'); 
subplot(1,2,2); imshow(Im); title('original'); 

代替由分割內核,我用imshow(filteredImage,[])