Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 自适应中值滤波码的一些错误 %%自适应中值滤波-代码 ip1=imread('lena.gif');%无失真图像 ip=imnoise(ip1,'盐和胡椒',0.25);%图像被“椒盐噪声”损坏 ip_中值_过滤器1=medfilt2(ip);%对窗口尺寸为3x3像素的带噪图像应用中值滤波 ip_median_filt2=medfilt2(ip[4,4]);%对窗口尺寸为4x4像素的带噪图像应用中值滤波器 图(1),clf; 子地块(2,1,1),imshow(ip,[]); 子地块(2,1,2),imshow(ip_中值滤波1,[]); %%现在,我们继续对噪声图像和图像进行自适应中值滤波 %%证明了该方法的效果优于标准中值滤波器 %%如上所示 %%在带噪输入图像的边缘像素周围填充零,以便 %%允许对图像的边缘像素进行处理 ip_边=零(212276); ip_转换=双(ip); %%%%%%%%%%下面这行似乎有错误 ip_边(11:202,11:266)=ip_边(11:202,11:266)+ip_转换; smax=9; 对于i=11:202 对于j=11:266 sx=3; sy=3; 而((sx0)和&(B0)和&(Dsmax)和&(sy>smax) ip_边(i,j)=ip_边(i,j); 结束 结束 结束 结束 结束 结束 图(2),clf; imshow(ip_-edge,[]);_Image_Matlab_Image Processing_Filter - Fatal编程技术网

Image 自适应中值滤波码的一些错误 %%自适应中值滤波-代码 ip1=imread('lena.gif');%无失真图像 ip=imnoise(ip1,'盐和胡椒',0.25);%图像被“椒盐噪声”损坏 ip_中值_过滤器1=medfilt2(ip);%对窗口尺寸为3x3像素的带噪图像应用中值滤波 ip_median_filt2=medfilt2(ip[4,4]);%对窗口尺寸为4x4像素的带噪图像应用中值滤波器 图(1),clf; 子地块(2,1,1),imshow(ip,[]); 子地块(2,1,2),imshow(ip_中值滤波1,[]); %%现在,我们继续对噪声图像和图像进行自适应中值滤波 %%证明了该方法的效果优于标准中值滤波器 %%如上所示 %%在带噪输入图像的边缘像素周围填充零,以便 %%允许对图像的边缘像素进行处理 ip_边=零(212276); ip_转换=双(ip); %%%%%%%%%%下面这行似乎有错误 ip_边(11:202,11:266)=ip_边(11:202,11:266)+ip_转换; smax=9; 对于i=11:202 对于j=11:266 sx=3; sy=3; 而((sx0)和&(B0)和&(Dsmax)和&(sy>smax) ip_边(i,j)=ip_边(i,j); 结束 结束 结束 结束 结束 结束 图(2),clf; imshow(ip_-edge,[]);

Image 自适应中值滤波码的一些错误 %%自适应中值滤波-代码 ip1=imread('lena.gif');%无失真图像 ip=imnoise(ip1,'盐和胡椒',0.25);%图像被“椒盐噪声”损坏 ip_中值_过滤器1=medfilt2(ip);%对窗口尺寸为3x3像素的带噪图像应用中值滤波 ip_median_filt2=medfilt2(ip[4,4]);%对窗口尺寸为4x4像素的带噪图像应用中值滤波器 图(1),clf; 子地块(2,1,1),imshow(ip,[]); 子地块(2,1,2),imshow(ip_中值滤波1,[]); %%现在,我们继续对噪声图像和图像进行自适应中值滤波 %%证明了该方法的效果优于标准中值滤波器 %%如上所示 %%在带噪输入图像的边缘像素周围填充零,以便 %%允许对图像的边缘像素进行处理 ip_边=零(212276); ip_转换=双(ip); %%%%%%%%%%下面这行似乎有错误 ip_边(11:202,11:266)=ip_边(11:202,11:266)+ip_转换; smax=9; 对于i=11:202 对于j=11:266 sx=3; sy=3; 而((sx0)和&(B0)和&(Dsmax)和&(sy>smax) ip_边(i,j)=ip_边(i,j); 结束 结束 结束 结束 结束 结束 图(2),clf; imshow(ip_-edge,[]);,image,matlab,image-processing,filter,Image,Matlab,Image Processing,Filter,我在与%%的行中得到一个错误: ??使用==>加上矩阵尺寸的错误必须一致。 错误==>在22 ip_边缘自适应(11:202,11:266)=ip_边缘(11:202,11:266)+ip_转换 Matlab告诉您问题是什么,为了能够添加ip_边缘和ip_转换的区域(11:202,11:266),它们需要具有相同的尺寸 ip_边缘区域的大小是192 x 256,我猜您的ip_转换矩阵当时的大小不同(无法确定,因为加载的lena gif不是标准的Matlab图像)。Matlab告诉您问题所在,以便

我在与%%的行中得到一个错误:

??使用==>加上矩阵尺寸的错误必须一致。 错误==>在22 ip_边缘自适应(11:202,11:266)=ip_边缘(11:202,11:266)+ip_转换


Matlab告诉您问题是什么,为了能够添加
ip_边缘
ip_转换
的区域(11:202,11:266),它们需要具有相同的尺寸


ip_边缘
区域的大小是
192 x 256
,我猜您的ip_转换矩阵当时的大小不同(无法确定,因为加载的lena gif不是标准的Matlab图像)。

Matlab告诉您问题所在,以便能够添加区域(11:202,11:266)对于
ip_边缘
ip_转换
,它们需要具有相同的尺寸


ip_边缘
区域的大小是
192 x 256
,我猜您的ip_转换矩阵当时的大小不同(无法确定,因为加载的lena gif不是标准的Matlab图像)。

您的错误与自适应滤波无关。只是矩阵尺寸不匹配

提示:不必显式指定图像的尺寸。 使用类似于:

%% Adaptive Median Filtering - The Code

ip1 = imread ('lena.gif');                  %% Undistorted image
ip = imnoise (ip1,'salt & pepper',0.25);    %% Image corrupted with 'Salt and Pepper Noise'

ip_median_filt1 = medfilt2(ip);             %% Apply median filter to noisy image with window dimensions of 3x3 pixels
ip_median_filt2 = medfilt2(ip,[4,4]);       %% Apply median filter to noisy image with window dimensions of 4x4 pixels
figure(1), clf;
subplot (2, 1, 1), imshow (ip, []);
subplot (2, 1, 2), imshow (ip_median_filt1, []);

%% We now proceed with the adaptive median filtering of the noisy image and 
%% prove that the results are better than those of the standard median filter 
%% shown above

%% Packing zeros around the edge pixels of the noisy input image so as to 
%% allow the facilitate the processing of edge-pixels of the image

ip_edge = zeros (212,276);

ip_convert = double (ip);

%%%%%%%%%% there seems to be error on the following line
ip_edge (11:202, 11:266) = ip_edge (11:202, 11:266) + ip_convert;

smax=9;

for i=11:202
    for j=11:266
        sx=3;
        sy=3;
        while ((sx<=smax) && (sy<=smax))
            ip_edge_min = ip_edge (i, j);
            ip_edge_max = ip_edge (i, j);
            ip_edge_median = median(median(ip_edge((i-floor(sx/2)):(i+floor(sx/2)),(j-floor(sy/2)):(j+floor(sy/2)))));
            for k= (i-floor (sx/2)) :( i+floor (sx/2))
                for l= (j-floor (sy/2)) :( j+floor (sy/2))
                    if ip_edge (k, l) < ip_edge_min
                        ip_edge_min = ip_edge (k, l);
                    end 
                    if ip_edge (k, l) > ip_edge_max
                        ip_edge_max = ip_edge (k, l);
                    end 
                End 
            end 
            A = ip_edge_median - ip_edge_min;
            B = ip_edge_median - ip_edge_max;
            if (A>0) && (B<0)
                C = ip_edge (i, j) - ip_edge_min;
                D = ip_edge (I) - ip_edge_max;
                if (C>0) && (D<0)
                    pledge (i, j) = ip_edge (i, j);
                    break
                else
                    ip_edge (i, j) = ip_edge_median;
                    break
                end 
            else 
                sx=sx+2;
                sy=sy+2;
                if (sx>smax) && (sy>smax)
                    ip_edge(i,j) = ip_edge(i,j);
                end 
            end
        end 
    end 
  end 
end


figure(2), clf;
imshow(ip_edge,[]);
或者,您也可以使用内置函数padarray

ip_edge = zeros(size(ip1) + 20);
ip_edge(11:end-10,11:end-10) = double(ip);
顺便说一句,你的代码效率非常低。Matlab的规则1是:永远不要循环!好吧,这并不总是可行的,但这是你应该瞄准的目标。 以下是滑动中值滤波的“精益”代码:

ip_edge = padarray(double(ip), [10 10])
这就是你所说的“适应性”吗?
祝您学习Matlab时好运:-)

您的错误与自适应滤波无关。只是矩阵的尺寸不匹配

提示:不必显式指定图像的尺寸。 使用类似于:

%% Adaptive Median Filtering - The Code

ip1 = imread ('lena.gif');                  %% Undistorted image
ip = imnoise (ip1,'salt & pepper',0.25);    %% Image corrupted with 'Salt and Pepper Noise'

ip_median_filt1 = medfilt2(ip);             %% Apply median filter to noisy image with window dimensions of 3x3 pixels
ip_median_filt2 = medfilt2(ip,[4,4]);       %% Apply median filter to noisy image with window dimensions of 4x4 pixels
figure(1), clf;
subplot (2, 1, 1), imshow (ip, []);
subplot (2, 1, 2), imshow (ip_median_filt1, []);

%% We now proceed with the adaptive median filtering of the noisy image and 
%% prove that the results are better than those of the standard median filter 
%% shown above

%% Packing zeros around the edge pixels of the noisy input image so as to 
%% allow the facilitate the processing of edge-pixels of the image

ip_edge = zeros (212,276);

ip_convert = double (ip);

%%%%%%%%%% there seems to be error on the following line
ip_edge (11:202, 11:266) = ip_edge (11:202, 11:266) + ip_convert;

smax=9;

for i=11:202
    for j=11:266
        sx=3;
        sy=3;
        while ((sx<=smax) && (sy<=smax))
            ip_edge_min = ip_edge (i, j);
            ip_edge_max = ip_edge (i, j);
            ip_edge_median = median(median(ip_edge((i-floor(sx/2)):(i+floor(sx/2)),(j-floor(sy/2)):(j+floor(sy/2)))));
            for k= (i-floor (sx/2)) :( i+floor (sx/2))
                for l= (j-floor (sy/2)) :( j+floor (sy/2))
                    if ip_edge (k, l) < ip_edge_min
                        ip_edge_min = ip_edge (k, l);
                    end 
                    if ip_edge (k, l) > ip_edge_max
                        ip_edge_max = ip_edge (k, l);
                    end 
                End 
            end 
            A = ip_edge_median - ip_edge_min;
            B = ip_edge_median - ip_edge_max;
            if (A>0) && (B<0)
                C = ip_edge (i, j) - ip_edge_min;
                D = ip_edge (I) - ip_edge_max;
                if (C>0) && (D<0)
                    pledge (i, j) = ip_edge (i, j);
                    break
                else
                    ip_edge (i, j) = ip_edge_median;
                    break
                end 
            else 
                sx=sx+2;
                sy=sy+2;
                if (sx>smax) && (sy>smax)
                    ip_edge(i,j) = ip_edge(i,j);
                end 
            end
        end 
    end 
  end 
end


figure(2), clf;
imshow(ip_edge,[]);
或者,您也可以使用内置函数padarray

ip_edge = zeros(size(ip1) + 20);
ip_edge(11:end-10,11:end-10) = double(ip);
顺便说一下,您的代码效率极低。Matlab的规则1是:永不循环!好吧,这并不总是可行的,但这是你应该瞄准的目标。 以下是滑动中值滤波的“精益”代码:

ip_edge = padarray(double(ip), [10 10])
这就是你所说的“适应性”吗?
祝你在学习Matlab时好运:-)

简单:你不能将两个不同大小的矩阵相加。简单:你不能将两个不同大小的矩阵相加。自适应中值滤波是一种新型滤波,它选择有噪声的候选矩阵并将中值应用于矩阵,我发现这种自适应滤波器不同于滑动中值滤波器。谢谢,我也学到了一些东西:-)顺便说一下,Matlab Central上有一些实现。看一看自适应中值滤波是一种新的滤波类型,它选择有噪声的候选对象并将中值应用到模型上,我发现这种自适应滤波不同于滑动中值滤波。谢谢,我也学到了一些东西:-)顺便说一下,Matlab Central上有一些实现。看看