繁体   English   中英

错误:MATLAB中的图像噪声检测

[英]Error: Image Noise detection in MATLAB

在实现用于图像中噪声检测的简单想法时出现错误。 I表示嘈杂的图像,并为I每个像素表示I(x,y) 定义了一个以I(x, y)为中心的大小为3X3滑动窗口。 首先,我们估计窗口的中心像素是否为噪点。 为了区别噪声和信号,我们计算窗口的平均值m和标准偏差s 如果像素在msm+s ,那么这是一个信号,否则就是噪声,我们将应用中值滤波器。

算法:

  1. 读取图像I
  2. 采取大小为3X3的滑动窗口或蒙版。
  3. 计算与蒙版的平均值m和标准偏差s
  4. 计算阈值如下: t1 = mst2 = m+s
  5. IF t1 <= I(x,y) and I(x,y) <= t2, THEN Result(x,y) = I(x,y) ELSE Result(x, y) = medfilt2(I(x,y)
  6. 在整个图像上重复步骤3、4和5。
  7. 显示结果图像。

我尝试如下实现此算法

clc;
close all;
clear all;

I=imread('lena.jpg');
I=rgb2gray(I);

Out = blockproc(I,[3 3],@(x) noisedetection(x.data(:)));

imshow(out);

功能noisedetection如下:

function x=noisedetection(y)
s=std2(y(:)); % Calculating Standard deviation
m=mean2(y(:)); % Calulating Mean
t1=m-s; % Threshold 1
t2=m+s; % Threshold 2
[m n]=size(y);

for i=1:m
    for j=1:n


if (t1<=y(i,j) & y(i,j)<=t2)
    iout(i,j)=y(i,j)
else
    iout(i,j)=medfilt2(y(i,j)) % Filtering only when the pixel does not fall in the interval [t1,t2] 
end
    end
end
x=iout

但是我收到以下错误

    Subscripted assignment dimension mismatch.

Error in blockprocInMemory (line 151)
    b(last_row_start:end,last_col_start:end,:) = lr_output;

Error in blockproc (line 237)
    result_image = blockprocInMemory(source,fun,options);

Error in detection (line 8)
Out = blockproc(I,[3 3],@(x) noisedetection(x.data(:)));

请帮我。

  1. blockproc为您提供了不同的块。 而是使用nlfilter。

  2. iout(i,j)=medfilt2(y(i,j))是错误的语句。 medfilt2仅执行中值过滤,而不会提供中值。 要获得中值,只需使用median(y(:))

  3. 这是错误的: (t1<=y(i,j) & y(i,j)<=t2)

另外,您还可以交叉发布。 检出: https : //dsp.stackexchange.com/questions/15033/error-image-noise-detection-in-matlab/15036?noredirect=1#comment25759_15036

$ 3 ^ rd $的说明在上面的链接中给出。

这意味着您没有为输出参数分配任何内容。 我猜你应该分配给x而不是iout (i, j)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM