【发布时间】:2014-02-16 02:10:22
【问题描述】:
我想在图像上应用 Sobel 和其他过滤器,但只有在原始输入图像上使用过滤器时才能看到过滤器的结果。但是如果我在 inout 图像的副本上实现过滤器,那么什么也不会发生,只会出现一个白色的输出图像。
在下面的代码中,我在原始inputImage 实现过滤器,但我想通过在copyImage 实现它来获得结果。
inputImage=imread('tex.png');
copyImage=double(inputImage);
for i=1:size(C,1)-2
for j=1:size(C,2)-2
%Sobel mask for x-direction:
Gx=((2*C(i+2,j+1)+C(i+2,j)+C(i+2,j+2))-(2*C(i,j+1)+C(i,j)+C(i,j+2)));
%Sobel mask for y-direction:
Gy=((2*C(i+1,j+2)+C(i,j+2)+C(i+2,j+2))-(2*C(i+1,j)+C(i,j)+C(i+2,j)));
%The gradient of the image
inputImage(i,j)=sqrt(Gx.^2+Gy.^2);
end
end
【问题讨论】:
-
从copyImage中删除
double,然后将for循环中的inputImage替换为copyImage。
标签: matlab image-processing computer-vision