Image recognition: extracting numbers from white paper
Mostrar comentarios más antiguos
I have a large dataset of coloured images, all with one person holding a white piece of paper with a printed number. I am trying to extract the number as a class label for each person. By binarizing the image and removing small areas I can create an image as shown. But from here, all implementations of the ocr function I have attempted fail to extract the number. I have also attempted using corner extraction, but this does not work easily as some candidates are obscuring the corners of the paper with their hands. Could anyone provide some tips on how to achieve this?
Code:
clc
clear all
close all
% Load an image
rgbImage = imread('person11.jpeg');
grayImage = rgb2gray(rgbImage);
% Binarize the image.
binaryImage = grayImage > 120;
% Remove small objects.
binaryImage = bwareaopen(binaryImage, 5000);
figure(1)
imshow(binaryImage);
title('Cleaned Binary Image');
% Use the 'CharacterSet' parameter to constrain OCR
results = ocr(binaryImage, 'CharacterSet', '0123456789', 'TextLayout','Block');
results.Text
Output lots of different numbers, not 11!
Image:

Respuesta aceptada
Más respuestas (1)
Image Analyst
el 10 de Feb. de 2019
Editada: Image Analyst
el 10 de Feb. de 2019
0 votos
First I would do color segmentation to find neutral colored regions (not what you have done). Use the Color Thresholder app on the Apps tab of the MATLAB tool ribbon to do this.
Then I would crop the region to only the paper they are holding. Then I would call the ocr() function in the Computer Vision System Toolbox.
Attach your original image if you still need help and I might be able to do some of it if you're unable to and I have time.
2 comentarios
Image Analyst
el 10 de Feb. de 2019
I just got back after being away all day. What did you accomplish while I was gone?
Categorías
Más información sobre Detect, Extract, and Match Features en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

