链接论文:论文
测试文档:testimage
这是我关于 haar 小波变换问题的代码。我认为文本 regconize 存在问题,它在我们的测试中不返回任何文本(文本矩阵到处都是 0)。所以我们需要另一个关于 HL 和 LH 的定义。
另一个,在论文的等式(13)中,我们对每个类使用 imfilter。而且我不了解等式(14)。
谢谢
clear all;
close all;
eps = 0.0000000001; %make epsilon
f = imread('testf3.png');
f = ~f;
%f = rgb2gray(f);
%f = im2bw(f);
imwrite(f,'testhaar.png');
%imshow(f);
[LL,LH,HL,HH ] = haarwavelet(f);
subplot(2,2,1);imshow(LL);title('LL image');
subplot(2,2,2);imshow(LH);title('LH image');
subplot(2,2,3);imshow(HL);title('HL image');
subplot(2,2,4);imshow(HH);title('HH image');
[m n] = size(HL);
M = zeros(size(HL));
% 9.5 is text c = T
% 6.5 is image c = I
% 5.5 is back ground c = X
% 7.5 is vertical line c = V
% 8.5 is horizontal line c = H
testtext = M;
testimage = M;
testvertical = M;
testhorizontal = M;
testbackground = M;
for i = 1:m
for j = 1:n
if (abs(1 - HL(i, j)) < eps && abs(1 - LH(i, j)) < eps)
M(i, j) = 9.5; %text
testtext(i, j) = 9.5;
end
if (abs(1 - HL(i, j)) < eps && abs(0 - LH(i, j)) < eps)
M(i, j) = 7.5; %vertical line
testvertical(i, j) = 7.5;
end
if (abs(0 - HL(i, j)) < eps && abs(1 - LH(i, j)) < eps)
M(i, j) = 8.5; %horizontal line
testhorizontal(i, j) = 8.5;
end
if (abs(0 - HL(i, j)) < eps && abs(0 - LH(i, j)) < eps && abs(0-LL(i, j)) < eps)
M(i, j) = 6.5; % image
testimage(i, j) = 6.5;
end
if (abs(0 - HL(i, j)) < eps && abs(0 - LH(i, j)) < eps && abs(2-LL(i, j)) < eps)
M(i, j) = 5.5; % back ground
testbackground(i, j) = 5.5;
end
end
end
% figure, imshow(M);
maskIT = [0 0.5 0;0.5 1 0.5;0 0.5 0];
maskH = [0 0 0;1 1 1;0 0 0];
maskV = [0 1 0; 0 1 0; 0 1 0];
%---------------------------------
restext=imfilter(double(testtext),maskIT);
figure;imshow(restext,[]);
%----------------------------------
resimage=imfilter(double(testimage),maskIT);
figure;imshow(resimage,[]);
%----------------------------------
resvertical=imfilter(double(testvertical),maskV);
figure;imshow(resvertical,[]);
%-------------------------------------
reshorizontal=imfilter(double(testhorizontal),maskH);
figure;imshow(reshorizontal,[]);
%------------------------------