Detecting text areas using bounding boxes for varying font sizes
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!