Unable to recognize letter labels in a image using ocr() function.
Afficher commentaires plus anciens
Hi, I tried using OCR() function to recognize letter labels (i/p's & o/p's) in the image below containing a logic circuit. The image is in grayscale uint8 format, so I converted it to RGB format and tried to use OCR() function to recognize letter labels. But the function doesn't work. Is it due to any noise present in the image. Can someone please suggest a way to make it work.
If the OCR() function can't be used, please suggest an alternative function that can be used on such images.

I tried using pattern recognition, it works, but I am looking for some function that can be used to locate the label letters in the image and draw a circle around them.
Réponse acceptée
Plus de réponses (4)
Image Analyst
le 19 Mar 2015
0 votes
First of all, remove blobs with areas larger than the number of pixels in a letter, like 200 or so. See my Image segmentation tutorial to learn how to do that. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 That will get rid of the circuitry and leave only the letters.
Then the OCR in the Computer Vision System Toolbox should work. http://www.mathworks.com/help/vision/ref/ocr.html#bt548t1-2_1
2 commentaires
Jack Smith
le 19 Mar 2015
Image Analyst
le 30 Oct 2021
@Jack Smith, saying ocr() doesn't work is a very strange thing to say since the answer you accepted does in fact use the ocr() function.
If you read the ocr() documentation, it says the characters must be at least 20 pixels high. Are yours that high or higher?
Also, you can see published papers on analyzing circuit diagrams and engineering drawings here:
azmi haider
le 13 Fév 2018
0 votes
Amazing work. Thanks
ali saren
le 9 Jan 2019
0 votes
Hi,
lots of thanks for your amazing code.
is there a simple way to delete these characters from the pick ?
we have their position but i want to make these words on the picture replace with white spaces .
4 commentaires
Image Analyst
le 9 Jan 2019
See Birju's code. See the roi variable. Just go down the rows using that to whiten the image there.
for row = 1 : size(roi, 1)
row1 = .....
col1 = ...
% etc
grayImage(row1:row2, col1:col2) = 255; % Whiten this rectangle.
end
ali saren
le 9 Jan 2019
thank you very much, what I coulden’t understand are the variables row1 and col1 that you have used. could you please explain a little bit more?
Image Analyst
le 9 Jan 2019
Did you look at roi? They're bounding boxes. So the format for each row is [xLeft, yTop, width, height].
for row = 1 : size(roi, 1)
thisROI = roi(row, :); % Extract [xLeft, yTop, width, height]
row1 = ceil(thisROI(2)); % yTop
row2 = row1 + thisROI(4); % yBottom = yTop + height
col1 = ceil(thisROI(1)); % xLeft
col2 = col1 + thisROI(3); % xRight = xLeft + width.
grayImage(row1:row2, col1:col2) = 255; % Whiten this rectangle.
end
ali saren
le 9 Jan 2019
yes, I've looked at roi it was a little bit confusing to me. but now with you explanation ir's crystal clear.
Thank you so much for your time
Nikhil Challa
le 30 Oct 2021
0 votes
Amazing Code!
Catégories
En savoir plus sur Convert Image Type dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
