For my assignment I have to locate subimages on larger image (simple OCR). I have text and sample image (e. g. single letter) and have to locate it's positions on larger image (which will be converted to .txt). I'm using Python (for easy use of matrices and FFT functions).

After rotating text (like https://vh.io/articles/2018-06-15.html) I calculate correlation matrix from images loaded as pixel matrices:

correlation_matrix = abs(ifft2(multiply(fft2(full), fft2(rot90(part)))))

Max correlation is correlation from matrix with largest absolute value. Then I iterate through full image matrix and if correlation[i, j] / max_correlation >= 0.9, then similarity is high enough and I know the letter is there.

  1. Is my reasoning and approach correct?
  2. How can I locate exact positions of letters in this manner? I need formatted text (with spaces, line breaks etc.).

Your Answer

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

Browse other questions tagged or ask your own question.