How to segment a paragraph into lines and words?

1 vue (au cours des 30 derniers jours)
SUBHAM KUMAR SAHOO
SUBHAM KUMAR SAHOO le 12 Fév 2019
Commenté : Guillaume le 13 Fév 2019
119.jpg
  2 commentaires
madhan ravi
madhan ravi le 12 Fév 2019
upload it as a text instead of picture
SUBHAM KUMAR SAHOO
SUBHAM KUMAR SAHOO le 12 Fév 2019
I have to do the segmentation on this image file. Is it not possible?

Connectez-vous pour commenter.

Réponse acceptée

Guillaume
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
segmented.png
  8 commentaires
SUBHAM KUMAR SAHOO
SUBHAM KUMAR SAHOO le 13 Fév 2019
Only the grey image is showing. there is no change in the o/p image after the last line coding.119grey.jpg
Guillaume
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by