2014-09-20 88 views
0

我有一個關於強度不均勻性的問題。我讀了紙,它定義的方法來計算基於平均濾波器的強度的不均勻性: enter image description here如何基於matlab平均濾波器計算強度不均勻

讓見我的問題,我有一個圖像I(下面的代碼),並用R = 3平均濾波器。我想根據公式(17)計算圖像變換J。你能幫我通過matlab代碼實現嗎?非常感謝。

這是我的代碼

%Create image I 
I=[3 5 5 2 0 0 6 13 1 
0 3 7 5 0 0 2 8 6 
4 5 5 4 2 1 3 5 9 
17 10 3 1 3 7 9 9 0 
7 25 0 0 5 0 10 13 2 
111 105 25 19 13 11 11 8 0 
103 105 15 26 0 12 2 6 0 
234 238 144 140 51 44 7 8 8 
231 227 150 146 43 50 8 16 9 
]; 
%% Create filter AF 
size=3; % scale parameter in Average kernel 
AF=fspecial('average',[size,size]); % Average kernel 
%%How to calculate CN and J 
CN=mean(I(:));%Correct? 
J=??? 

回答

1

你非常接近!平均強度計算正確;所有你缺少計算J是適用與fspecial定義圖像過濾器:

這裏是代碼:

clc 
clear 

%Create image I 
I=[3 5 5 2 0 0 6 13 1 
0 3 7 5 0 0 2 8 6 
4 5 5 4 2 1 3 5 9 
17 10 3 1 3 7 9 9 0 
7 25 0 0 5 0 10 13 2 
111 105 25 19 13 11 11 8 0 
103 105 15 26 0 12 2 6 0 
234 238 144 140 51 44 7 8 8 
231 227 150 146 43 50 8 16 9 
]; 

% Create filter AF 
size=3; % scale parameter in Average kernel 
AF=fspecial('average',[size,size]); % Average kernel 

%%How to calculate CN and J 
CN=mean(I(:)); % This is correct 

J = (CN*I)./imfilter(I,AF); % Apply the filter to the image 

figure; 

subplot(1,2,1) 
image(I) 

subplot(1,2,2) 
image(J) 

在下列所得:

enter image description here

+0

+投票1爲偉大的答案。但是,讓我們看看AF濾鏡的定義。這個代碼是否正確AF = imfilter(Img,fspecial('disk',sigma),'conv','replicate'); – user3051460 2014-09-20 15:39:35

+1

很高興幫助!是的,你的過濾器是正確的。 – 2014-09-20 16:27:14