MATLAB Answers

Find image in scene

9 views (last 30 days)
Highscore on 18 Apr 2020
Commented: Highscore on 22 Apr 2020
Hi, my problem is shown in the images below:
I am trying to find the second image in the first image. The more complex problem I'm working on is that I can find the number displayed in the second picture out of a database of numbers (for example; if the number was 27, the program would run in a loop and remember 27 was the best matching number). But since I am stuck on already comparing 2 pictures, this is for later.
Any tips on how to handle this problem? I tried the code in the link below, but I got no results so this seems not the right approach.
I am not a coder at all, so I hope there is already an existing code for this type of problem I didn't find myself!


Show 2 older comments
Image Analyst
Image Analyst on 21 Apr 2020
It really depends on how general your template and scene are. In that one specific case you showed, a black one on a white background, it's easy to find. But if you have partially obscured characters on complicated backgrounds, it can be quite complicated. For example, if you wanted to find a small red patch neighboring a green and blue patch (like the red patch on the paper on the wall).
So assuming that all images are alphanumeric characters on a uniform white patch, it's pretty easy. Just find the white patch, check it to make sure it's only black and white, not colored stuff in it like that frame on the stack of books on the floor, crop it out, and call ocr().
Highscore on 21 Apr 2020
Yes I completely have these matters in my own hands, so it will always be a black number (one or two digits) in a white background. Thanks for the help, I will try to find the pieces of code online to create this script :).
Already tried an ocr() example (link below) but I haven't found any text at all on my image (the 2 seperate pictures).
I'll try to create your method, if it still does not work I'll put the code here because there would obviously be a mistake in it.
Thanks for the fast replies
Highscore on 22 Apr 2020
Hey I'm working on your proposed method but I don't know how to handle the "make sure it's only black and white".
I've edited your SimpleColorDetection() for the colo white (170-255 on the rgb scale) that led me to the following result:
So now I want to only have the white background with the black 1 on it to call ocr() that would give me "1" as output, but I have no idea on how to begin on this. If I try to run ocr() on this I still get no output, so I got no idea how cropping it would give me an output.

Sign in to comment.

Answers (0)

Sign in to answer this question.

Translated by