Circle detection | Radio button detection | OMR

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
legend
Posts: 4
Joined: 2018-07-30T12:10:59-07:00
Authentication code: 1152

Circle detection | Radio button detection | OMR

Post by legend »

Hi

I want to detect Radio button selection option in the image like below. How can I do that? Thanks!

Image

Image

Image
legend
Posts: 4
Joined: 2018-07-30T12:10:59-07:00
Authentication code: 1152

Re: Circle detection | Radio button detection | OMR

Post by legend »

please do the needful
legend
Posts: 4
Joined: 2018-07-30T12:10:59-07:00
Authentication code: 1152

Re: Circle detection | Radio button detection | OMR

Post by legend »

It seems no one read this Topic :(
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Circle detection | Radio button detection | OMR

Post by snibgo »

Your question is too vague. Do images always have three options? Do you need to detect them all? Are they always in the same position? If so, just examine a pixel and test for black or white. If the positions vary, the task is messy. You might first search for the semi-circles.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Circle detection | Radio button detection | OMR

Post by fmw42 »

I would suggest you create a template with full circle (and possible the word Option in the same font), then use compare with -subimage-search to locate a circle. You can test two templates; one with the dot in the center and one without, if you need to located each option. As snibgo has said your question is vague and we do not know exactly what you are trying to do.

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
legend
Posts: 4
Joined: 2018-07-30T12:10:59-07:00
Authentication code: 1152

Re: Circle detection | Radio button detection | OMR

Post by legend »

IM version: latest version
platform : Command Line or .NET
------------------------------------------------------
1. Do images always have three options? --> Yes
2. Do you need to detect them all? --> Yes
3. Are they always in the same position? --> No, it can be anywhere in image

How to find the semi-circles. ?, Please guide me.

Thank You
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Circle detection | Radio button detection | OMR

Post by fmw42 »

Latest image does not give enough information, especially at some later time when this post is older. Best to respond with 6.9.10.8 or 7.0.8.8 if that is what you are really using.

Your platform is either Linux (some specified type), Windows version, Mac OSX version.

You should be testing for full circles, since scans do not always produce the same shape.

Have you read:

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Circle detection | Radio button detection | OMR

Post by snibgo »

There are many ways of doing this. For example:

1. Make a sample selected.png and nosel.png:

Code: Select all

%IMG7%magick ^
  rdSNzgq.png ^
  +write x.png ^
  ( +clone ^
    -crop 20x18+541+25 +repage ^
    +write selected.png ^
    +delete ^
  ) ^
  -crop 21x21+16+24 +repage ^
  nosel.png
2. Find the first reasonable match in the first image:

Code: Select all

%IMG7%magick compare ^
  -metric RMSE -subimage-search ^
  tVrbBlZ.jpg ^
  selected.png ^
  -dissimilarity-threshold 1 ^
  -similarity-threshold 0 ^
  NULL:
The result is:

Code: Select all

22215.9 (0.338993) @ 356,42
3. Crop that rectangle out into f1.png, and over-paint it white, writing to tmp.png.

Code: Select all

%IMG7%magick ^
  tVrbBlZ.jpg ^
  -fill White ^
  ( +clone ^
    -crop 20x18+356+42 +repage ^
    +write f1.png ^
    +delete ^
  ) ^
  -draw "rectangle 356,42 376,60" ^
  tmp.png
4. Is f1.png more like selected.png, or more like nosel.png?

Code: Select all

magick compare -metric RMSE f1.png selected.png NULL:
22215.9 (0.338993)

magick compare -metric RMSE f1.png nosel.png NULL:
38363.3 (0.585386)
The score is lower for selected.png, so f1.png is "selected".

Repeat from step 2, using tmp.png as the input, until no more matches are found (ie the score is low).
snibgo's IM pages: im.snibgo.com
Post Reply