1

I have a problem when I code matlab program and really need your help

I have a binary image (only 0 and 1) I use haar wavelet transform by matlab code :

[LL,LH,HL,HH] =dwt2( f, 'haar');

I also have four subimages.

LL : has maximun is 2 and min is 0 ( in this we have 0 - 0.5 - 1 - 1.5 - 2)

HL and LH and HH: have max is 1 and min is -1 ( in this we have -1 - (-0.5) - 0 - 0.5 - 1)

But now, because this is a binary image so I want our result just belong to 0 and 1. May be we can use low passfilter is OR logical and high passfilter is XOR.

But I don't know how to explain this and code, Please help me.

Thank you so much

Machavity
  • 30,841
  • 27
  • 92
  • 100
user3607620
  • 11
  • 1
  • 4
  • 1
    Why would you want to change the four subbands so that they're converted to 0 and 1? Don't you want to maintain that precision for further decomposition? Also if you change the result to `[0,1]` you won't be able to faithfully reconstruct your original image – rayryeng May 13 '14 at 15:35
  • Can you provide a link to this said paper? That theory doesn't make any sense to me – rayryeng May 13 '14 at 19:26
  • Thanks for your reply, Just because I read a paper for recognize the figurer and text by haar wavelet transform. In this paper, they note that if a pixel have high coefficient in HL and LH that mean this is text, and low in HL and LH and high in LL is image, I see that they note high coefficient is 1 and low is 0. I also send you this paper, this problem from page 7-8) if you have free time please give me some note. ( http://www.mediafire.com/download/9k7gp2c3ce032qr/1-parameter+-+free+geometric+document+layout+analysis.pdf ) Thanks you so much – user3607620 May 13 '14 at 19:31
  • It seems that they only consider values that are `0` and `1`. Any other values (`0.5` or `< 0`) are ignored. – rayryeng May 13 '14 at 19:39
  • Can we change LL value to -1 to 1. beause it quite different from HL and LH , HH . I think I will try to code now and hope this will work. It really important for me. I don't know that we have another technique to detect image and text in a docmunet? I will also attach an document example here: http://www.mediafire.com/view/myfiles/#bxolb7wbmtz8dw5. I follow above paper but there is some problem for me, an example is kernel s in smoothing projection ( page 3) of paper. Could I continue to talk with you a bout this problem, I can send you my code and we can understand this easier. Thank you – user3607620 May 14 '14 at 08:07
  • I'm just post attached my code below, and see there are something wrong if we only use 0 and 1. and I'm not sure about use filter fo regconize V (x,y) – user3607620 May 14 '14 at 13:32

1 Answers1

0

Link paper : paper
Test document: testimage

This is my code a bout the problem with haar wavelet transform. I think there are problem with text regconize, It return no text in our test ( matrix of text is 0 everywhere). So we need another definition on HL and LH.

Another, on equation (13) of paper, we use imfilter fo each class. And i'm not understand about equation (14).

Thank you

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,[]);

%------------------------------
AustinWBryan
  • 3,249
  • 3
  • 24
  • 42
user3607620
  • 11
  • 1
  • 4