extract text from image
129 views (last 30 days)
this code extract object random i want to extract letter line by line sequential
%%Image segmentation and extraction
title('INPUT IMAGE WITH NOISE')
%%Convert to gray scale
if size(imagen,3)==3 % RGB image
%%Convert to binary image
threshold = graythresh(imagen);
%%Remove all object containing fewer than 30 pixels
imagen = bwareaopen(imagen,30);
%%Show image binary image
title('INPUT IMAGE WITHOUT NOISE')
%%Label connected components
%%Measure properties of image regions
%%Plot Bounding Box
[r,c] = find(L==n);
Image Analyst on 22 Dec 2013
It's not random, though you don't know the algorithm it uses (it's top left to bottom right, column by column).
You will need to find each line and extract it before you label. See attached demo, which will produce this:
There is not OCR package built in to MATLAB. You'll have to find one or do it yourself.
More Answers (3)
deeksha h r on 13 Aug 2016
respected sir,the code used is displaying segmented letter but we need segmented line to be displayed ie each text line from the image is to be displayed.can you please help us with this code
Sharad Sirsat on 23 Nov 2019
You dont need to used "imagen = bwareaopen(imagen,30);" over here, Simply after converting image into binary,Use " bwlabel" to count number of character/objects in an image,After that in an image you can find the centroid of each character and then using Regionprops find their Length, Width to create a bounding box around character.Once you have done bounding box you can crop character individually by giving original image input.
Note: For centroid, bounding box(regionprops) and for imagecrop apply forloop till the counted no of objects/characters.