detected Image and text in document.

조회 수: 7 (최근 30일)
Tran Tuan Anh
Tran Tuan Anh 2014년 5월 21일
댓글: Tran Tuan Anh 2014년 5월 26일
0 down vote favorite
I have a binary image (image1). Now I want to detection where is the figure ( may be include big text) in original image. I use haar wavelet transform and detec a image B include some position may be the figure of A. (image 2). If I use image A - image B = image C (image 3) it may be not good be cause we have some boundary. Now I want remove the boundary or detect exactly the figure in image A? how to do that ?. I try use conected component but it run over time.
There is my image: Image A:
Image B:
Image C:
Image A- imageB =Image C ( that mean if A(i,j)==1 and B(i,j)==1 then C(i,j)=0;)
Please help me. Thank you so much

답변 (2개)

Image Analyst
Image Analyst 2014년 5월 23일
편집: Image Analyst 2014년 5월 23일
Take the image, call imfill(), then erode it enough to make the letters disappear. Then use imreconstruct. See attached demos.
  댓글 수: 6
Image Analyst
Image Analyst 2014년 5월 24일
It looks like B gets all the large blobs. There are a few small scattered dots around the big blobs and it's not picking those up. As far as it's concerned if it's small it could be text. If you want to capture the small surrounding dots, call imclose(). It will dilate the large blobs to engulf the small blobs or connect to nearby blobs, then it will erode to shrink it back down to the original size but without breaking any connections that were made during dialation.
closedImage = imclose(binaryImage, true(9)); % Use whatever window size you want.
Tran Tuan Anh
Tran Tuan Anh 2014년 5월 26일
편집: Tran Tuan Anh 2014년 5월 26일
Thank you for your answer, I will try it. In another hand I have a problem too in haar wavelet tranforms. I try with a binary image and use this algorithm to detect LL, LH, HL, HH: (all information just in my paper post above - page 8-9)
And I base on this to detect where is the text,image,horizontal,vertical:
I follow this but there is some problem, I can't detect the text, that mean if I use the pixel has high coefficient in LH and high coefficient in HL, they will give me a bad result. I will post my code below in answer, could you help me if there is something wrong? Thank you so much, it very important with me.

댓글을 달려면 로그인하십시오.


Tran Tuan Anh
Tran Tuan Anh 2014년 5월 26일
편집: Tran Tuan Anh 2014년 5월 26일
There is my code to find haar wavelet tranforms:
function [LL,LH,HL,HH] = haar01(f)
eps=0.00000000000001;
[m,n]=size(f);
for i=1:m/2
for j=1:n/2
if(2*i+2>m||2*j+2>n)
f(2*i,2*j+2)=1;
f(2*i+2,2*j)=1;
end
LL(i,j)=((f(2*i,2*j)|f(2*i+2,2*j))&(f(2*i,2*j)|f(2*i,2*j+2)));
end
end
for i=1:m/2
for j=1:n/2
if(2*i+2>m||2*j+3>n||2*j+1>n)
f(2*i,2*j+3)=0;
f(2*i,2*j+1)=0;
f(2*i+2,2*j)=0;
end
LH(i,j)=((f(2*i,2*j)|f(2*i+2,2*j)) & xor(f(2*i,2*j+1),f(2*i,2*j+3)));
end
end
for i=1:m/2
for j=1:n/2
if(2*i+3 > m ||2*i+1>m||2*j+2>n)
f(2*i+1,2*j)=0;
f(2*i,2*j+2)=0;
f(2*i+3,2*j)=0;
end
HL(i,j)=(xor(f(2*i+1,2*j),f(2*i+3,2*j)) & ((f(2*i,2*j)|f(2*i,2*j+2))));
end
end
for i=1:m/2
for j=1:n/2
if(2*i+1>m||2*i+3>m||2*j+1>n||2*j+3>n)
f(2*i+1,2*j)=0;
f(2*i+3,2*j)=0;
f(2*i,2*j+1)=0;
f(2*i,2*j+3)=0;
end
HH(i,j)=(xor(f(2*i+1,2*j),f(2*i+3,2*j)) & xor(f(2*i,2*j+1),f(2*i,2*j+3)));
end
end
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');
end
There is my main function:
f=imread('testtext1.png');
f=rgb2gray(f);
f=im2bw(f);
[LL,LH,HL,HH] = haar01(f);
[m n]=size(LH);
M=zeros(size(LH));
testext=M;
testimage=M;
testvertical=M;
testhorizontal=M;
testbackground=M;
for i=1:m
for j=1:n
if ((1-abs(HL(i,j)))<eps && (1-abs(LH(i,j))) < eps )
M(i,j)=1000.5; %text
testext(i,j)=1000.5;
end
if (abs(0-HL(i,j))<eps && abs(0-LH(i,j)) < eps && abs(0-LL(i,j)) < eps)
M(i,j)= 500.5; % image
testimage(i,j)=500.5;
end
if (abs(1-HL(i,j))<eps && abs(0-LH(i,j)) < eps )
M(i,j)=7.5; %horizontal line
testhorizontal(i,j) = 100.5;
end
if (abs(0-HL(i,j))<eps && abs(1-LH(i,j)) < eps )
M(i,j)=8.5; %horizontal line
testvertical(i,j)= 200.5;
end
if (abs(0-HL(i,j))<eps && abs(0-LH(i,j)) < eps && abs(1-LL(i,j)) < eps)
M(i,j)= 5.5; % back ground
testbackground(i,j)=50.5;
end
end
end
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(testext),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,[]);
%figure;imshow(reshorizontal,[]);
figure,imshow(testext);
V1=resvertical;
V2=resimage;
V3=reshorizontal;
V4=restext;
[a b]=size(V2);
D=zeros(size(V4));
for i=1:a
for j=1:b
if V4(i,j)>=1000.5;
D(i,j)=V4(i,j);
end
end
end
figure,imshow(D,[]);
There is my test image ( take from the paper) but reslut look so bad ( reslut very good in the paper)
Or this image:
Once a gain, thanks for your help
  댓글 수: 6
Image Analyst
Image Analyst 2014년 5월 26일
Why don't you just threshold and find the areas of all the blobs? All the text will be in a narrow range. Any outliers (bigger or smaller) will be non-letters and might be considered as noise (if smaller) or part of a figure (if bigger).
Tran Tuan Anh
Tran Tuan Anh 2014년 5월 26일
Could you show me more detail a bout this way ? and I will try this. I have try a lot in haar but, the result still not good. I think I will try another way, Thank you so much,

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Signal Analysis에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by