How to segment a paragraph into lines and words?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Réponse acceptée
Guillaume
le 12 Fév 2019
Modifié(e) : Guillaume
le 12 Fév 2019
Of course it's possible to segment the file. It's fairly trivial as well. Just close the image (if you're working with white text on black background which you should be, or open if you're working with black text on white background) and get the bounding box of the resulting objects in the image:
[rawimage, map] = imread('119.jpeg.png'); %for some reason the source image is indexed
greyimage = ind2gray(rawimage, map); %convert to greyscale
bwimage = ~imbinarize(greyimage); %for processing, binarise and invert so text is white on black background
joinedimage = imclose(bwimage, strel('square', 5)); %experiment with different structuring elements. This one works fine with your image
props = regionprops(joinedimage, 'BoundingBox'); %get bounding box of the objects
figure;
imshow(greyimage); %display image
arrayfun(@(prop) rectangle('Position', prop.BoundingBox, 'EdgeColor', 'red'), props); %and bounding boxes
8 commentaires
Guillaume
le 13 Fév 2019
vertcat(props.BoundingBox). It shows undefined variable "props".
No error is showing.
These two statements are contradictory. If you get an undefined variable "props" with vertcat(props.BoundingBox), then you'll get the same error with:
arrayfun(@(prop) rectangle('Position', prop.BoundingBox, 'EdgeColor', 'red'), props); %and bounding boxes
, the line that draws the bounding boxes.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Convert Image Type dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!