【问题标题】:How to calculate intensity inhomogeneity based on average filter by matlab如何通过matlab基于平均滤波器计算强度不均匀性
【发布时间】:2014-10-07 13:50:58
【问题描述】:

我有一个关于强度不均匀性的问题。我读了一篇论文,它定义了一种基于平均滤波器计算强度不均匀性的方法:

让我们看看我的问题,我有一个图像 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=???

【问题讨论】:

    标签: matlab image-processing


    【解决方案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)
    

    结果如下:

    【讨论】:

    • +投票 1 以获得最佳答案。但是,让我们看看 AF 滤镜的定义。这段代码是否正确 AF = imfilter(Img,fspecial('disk',sigma),'conv','replicate');
    • 很高兴为您提供帮助!是的,您的过滤器是正确的。
    猜你喜欢
    • 1970-01-01
    • 2017-09-10
    • 1970-01-01
    • 2018-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多