0
$\begingroup$

About this project: Older images have the date they where taken placed on the image, in the bottom left hand corner. The goal is to extract this date and put it in the EXIF data of the scanned photo.

I am new to the challenge of working with images. I have a code playground and git repo I am working with and posting my results, and have made some progress. But I have hit a wall with dealing with the noise near the extracted text. I am reaching out for any assistance and direction to solve this noise problem.

What I have done thus far: https://gitlab.com/51m0nt3r4aar/OCR_Img_Date_From_Scanned_Jpeg/blob/master/ImageManipPLayground.pdf

What I need help with: the Morph-Close did not remove the largest bits of noise, as seen in the last image, yet doing more morphs has not been successful. I am looking for any guidance to help solve this problem.

Thanks!

$\endgroup$
  • $\begingroup$ Can I please ask what is your next step? So, if you had those pixels filled in closer to the shape of the digits, what would you do next? $\endgroup$ – A_A Jun 14 '18 at 17:40
  • $\begingroup$ run OCR on them, and parse the results. I'm just stuck on removing the extra noise. $\endgroup$ – Simon Terhaar Jun 14 '18 at 18:40
  • $\begingroup$ Alright, but maybe the method you are using to do OCR can handle noisy input (?). What sort of OCR are you thinking of doing? $\endgroup$ – A_A Jun 14 '18 at 18:52
1
$\begingroup$

The shapes you are interested in are very regular while the noise you are trying to deal with will be less regular. Ideally, you will only have two shapes at the end of your processing: wide rectangles for the horizontal parts of the display and tall rectangles for the vertical parts. You can leverage this fact in how you shape your structuring element when you use opening to remove noise.

This code is for Matlab (or Octave, its free cousin), but should easy to implement in Python. Note that I screen grabbed the image from your GitLab file and resized it - so these dimensions likely won't match yours exactly. I also inverted the image so the foreground is white. Also, the images below were resized to 400% before posting.

pkg load image
img = imread("download.png");
img = img * 255;
imshow(img)

input image

First, use a wide structuring element for opening so only wide rectangles are kept.

SE_h = strel('rectangle',[1,8]);
h_lines = imerode(img, SE_h);
h_lines_reconstructed = imdilate(h_lines, SE_h);
imshow(h_lines_reconstructed)

horizontal components

The repeat for tall rectangles:

SE_v = strel('rectangle',[8,1]);
v_lines = imerode(img, SE_v);
v_lines_reconstructed = imdilate(v_lines, SE_v);
imshow(v_lines_reconstructed)

vertical components

Recombine and display:

combined = or(v_lines_reconstructed, h_lines_reconstructed);
imshow(combined);

horizontal and vertical combined

$\endgroup$
0
$\begingroup$

Another track you can follow to improve recognition is to take advantage of the specific shape of seven-seg digits.

A solution that may work on both noisy and clean binarized images would be to create ten masks corresponding to the tenth seven-seg digits then for each digit find the maximums of the SAD (Sum of Absolute Differences. Those maximums indicate a strong probability of presence of the digit at the corresponding location.

I guess it could be even more efficient if you take advantage of the specific date location on the image (bottom-left with dd/mm/yyyy format with a space between...) because you can remove lots of false alarm by drastically reducing the search area.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.