根据最后一个公式计算w(x,y), 实际上就是计算梯度水平(水平和垂直方向两个方向综合)
I = imread('test3.jpg'); %读入图象
subplot(121);imshow(I);
I = double(rgb2gray(I));
[m,n]=size(I);
H1 = [-1 -2 -1
0 0 0
1 2 1];
H2 = [-1 0 1
-2 0 2
-1 0 1];
w0 = (abs(conv2(I,double(H1),'same')) + abs(conv2(I,double(H1),'same')))/2+ones(m,n);
subplot(122);imshow(uint8(w0));
w = 1./w0;
最后一个问题,它滤波后图像 Io(x,y) 用matlab怎么写
追答clear all;
I = imread('lena.bmp'); %读入图象
% I = rgb2gray(I);
figure;imshow(I);
I = double(I);
[m,n]=size(I);
H1 = [-1 -2 -1
0 0 0
1 2 1];
H2 = [-1 0 1
-2 0 2
-1 0 1];
w0 = (abs(conv2(I,double(H1),'same')) + abs(conv2(I,double(H1),'same')))/2+ones(m,n);
w = 1./w0;
%计算N(x,y)
% 设窗口D=7;
D = 7;
N = zeros(m,n);
for x = 1:m-D
for y = 1:n-D
N(x,y)=sum(sum(w(x:x+D-1,y:y+D-1)));
end
end
%计算I0
for x = 1:m-D
for y = 1:n-D
I0(x,y)= sum( sum( w(x:x+D-1,y:y+D-1).*I(x:x+D-1,y:y+D-1)) )./N(x,y);
I0h(x,y)=max(I0(x,y),I(x,y));
end
end
figure; imshow(uint8(I0h));