checkbox detection
Re: checkbox detection
@Fred: Wouldn't that be slower?
edit: also less reliable because of the X, Y shift.
edit: also less reliable because of the X, Y shift.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: checkbox detection
It might be slower, but there are ways to speed it up. It will be more accurate with respect to x,y shifts because it finds the best shift that makes the match score better. You can limit the search to a region around your approximately known locations. You can do the search at multiple resolutions to speed it up. You can use my faster FFT based scripts such as normcrosscorr, if on a Unix-like system.
Perhaps you should post an example image of what you are trying to search for the check boxes.
Perhaps you should post an example image of what you are trying to search for the check boxes.
Re: checkbox detection
I already crop separate images of each checkbox. Here are some examples:
Do you think subimage search would work better/faster than the "counting black pixels on every Y" approach?
Do you think subimage search would work better/faster than the "counting black pixels on every Y" approach?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: checkbox detection
I have no idea, since I do not know what you are trying to match to. Can you provide an image that shows an image that you want to test?
Counting black does not seem to me to be an accurate method, depending upon what you are testing?
Re: checkbox detection
I want to match this image in one of these 4 boxes:
Last edited by cso on 2017-09-29T11:49:56-07:00, edited 2 times in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: checkbox detection
Your image does not show up! However I am able to get to it. I do not understand why you want to match those templates against a fully black square? If you want to find all squares that are black, use a black template.
Perhaps I do not understand what your goal is? Please explain the project in more detail and the reason behind the project.
Are you trying to detect if a student has filled in a checkbox? Or are you just trying to detect the location of checkboxes whether filled or not?
Perhaps I do not understand what your goal is? Please explain the project in more detail and the reason behind the project.
Are you trying to detect if a student has filled in a checkbox? Or are you just trying to detect the location of checkboxes whether filled or not?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: checkbox detection
OK you have now changed the image to an empty check box. Are you trying to find the location of an empty check box or any checkbox that is filled, empty or partially filled? Why not just find the black outline using a template that is transparent in the center and outside where it is white. You can do a masked compare to detect the black and not care what is inside it.
Re: checkbox detection
Sorry, edited the post, you're too fast (thanks!) and I was sloppy! I don't have fully black squares anymore, I only ticked check boxes and non ticked ones (empty).
Re: checkbox detection
I'm not trying to find the location of the boxes. I already know the location of the boxes (sometimes there is a small deviation of some pixels which is the X/Y shift you see in the group of the 4 images) and crop them up in individual images.
What I want to know is whether the cropped image of the checkbox is empty or ticked/filled.
What I want to know is whether the cropped image of the checkbox is empty or ticked/filled.
I don't understand, can you please illustrate?Why not just find the black outline using a template that is transparent in the center and outside where it is white. You can do a masked compare to detect the black and not care what is inside it.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: checkbox detection
I would suggest you use compare to align the boxes. Then you can count the number of black pixels or get the average gray level value.
Re: checkbox detection
@Fred: I tried, it doesn't work well.
I read your solution in this thread: https://www.imagemagick.org/discourse-s ... hp?t=31295
I have to hand-tune the threshold to make it work.
I also read this, maybe I should use morphology?
http://www.imagemagick.org/Usage/compare/#sub-image
Looks complicated though.
Other ideas?
I read your solution in this thread: https://www.imagemagick.org/discourse-s ... hp?t=31295
I have to hand-tune the threshold to make it work.
I also read this, maybe I should use morphology?
http://www.imagemagick.org/Usage/compare/#sub-image
Looks complicated though.
Other ideas?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: checkbox detection
You have not tried using masked compare. See viewtopic.php?f=4&t=31053
Re: checkbox detection
Ok maybe cropping the individual boxes is not a good idea after all.
To reset the problem, this is my larger image and I want to classify all boxes in this image as ticked or non-ticked.
Fred, what would you use?
To reset the problem, this is my larger image and I want to classify all boxes in this image as ticked or non-ticked.
Fred, what would you use?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: checkbox detection
I would use the last two as separate reference images to match all the others using a compare -subimage-search. If one or the other match better than some threshold, you know it is not checked if the bottom one and checked if the second from the bottom one. But you should pad the other with a little more white so that the reference images have room to move to the best location.