|
楼主 |
发表于 2008-1-18 14:31
|
显示全部楼层
回复 8楼 的帖子
刚才发现uint写错了,但是还是有错切磋我错误
>> clear all
I = imread('1.bmp');
Img = uint8(I);
alf=3;
n=10;%定义模板大小
n1=floor((n+1)/2);%计算中心
for i=1:n
for j=1:n
b(i,j) =exp(-((i-n1)^2+(j-n1)^2)/(4*alf))/(4*pi*alf);
end
end
Img_n = uint8(conv2(Img,b,'same'));
K=uint8(imfilter(Img,b));
Img_n2=uint8(imfilter(Img,b,'conv'));
J=(Img_n2)-Img_n;
flag=mean(J(:))
subplot(131),imshow(I);title('原图')
subplot(132),imshow(Img_n);title('卷积运算图')
subplot(133),imshow(K);title('相关运算图')
figure(2),surf(b);
Warning: CONV2 on values of class UINT8 is obsolete.
Use CONV2(DOUBLE(A),DOUBLE(B)) or CONV2(SINGLE(A),SINGLE(B)) instead.
> In uint8.conv2 at 11
??? Function 'conv2' is not defined for values of class 'double' and attributes 'full 3d real'.
Error in ==> uint8.conv2 at 20
y = conv2(varargin{:}); |
|