[英]Error: Image Noise detection in MATLAB
在实现用于图像中噪声检测的简单想法时出现错误。 让I
表示嘈杂的图像,并为I
每个像素表示I(x,y)
。 定义了一个以I(x, y)
为中心的大小为3X3
滑动窗口。 首先,我们估计窗口的中心像素是否为噪点。 为了区别噪声和信号,我们计算窗口的平均值m
和标准偏差s
。 如果像素在ms
到m+s
,那么这是一个信号,否则就是噪声,我们将应用中值滤波器。
算法:
I
3X3
的滑动窗口或蒙版。 m
和标准偏差s
。 t1 = ms
和t2 = m+s
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)
我尝试如下实现此算法
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(:)));
请帮我。
blockproc为您提供了不同的块。 而是使用nlfilter。
iout(i,j)=medfilt2(y(i,j))
是错误的语句。 medfilt2仅执行中值过滤,而不会提供中值。 要获得中值,只需使用median(y(:))
。
这是错误的: (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.