2014-09-20 80 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