Detecting text areas using bounding boxes for varying font sizes
1 view (last 30 days)
Show older comments
I am trying to write a code that would draw bounding boxes around the text areas with varying font sizes.So far I have written a following code.
Image=imread('http://www.pakistantoday.tv/wp-content/uploads/2016/09/pti-chairman-imran-khan-media-ta.jpg');
grayImage=rgb2gray(Image);
edgedImage=edge(grayImage,'sobel','vertical');
seDilated=strel('rectangle',[1,20]);
dilatedImage=imdilate(edgedImage,seDilated);
seEroded=strel('rectangle',[5,5]);
erodedImage=imerode(dilatedImage,seEroded);
connectedComp=bwconncomp(erodedImage,4);
regions=regionprops(connectedComp,'BoundingBox');
imshow(grayImage);
hold on;
for i=1:length(regions)
box=regions(i).BoundingBox;
if(box(4)>10) %controlling height of each bounding boxes
if(box(3)/box(4)>1) % since width is normally larger
rectangle('Position',box,'EdgeColor','b','LineWidth',3);
end
end
end
So far I am NOT getting good results.As you can see below I am getting two many bounding boxes in the single text region and even some regions are not entirely getting detected.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/156366/image.png)
I want to use vertical projection information into my code as I am sure it would detect areas with varying font sizes pretty well as it will help determine the vertical height of the bounding boxes.Any other suggestion in code is welcome.
plot(sum(edgedImage,2)) % this plot displays text region areas inside the image
Some useful hints are available in the following paper but I am NOT able to implement that.
0 Comments
Answers (0)
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!