locating 'timing marks' in an image

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
pitosalas

locating 'timing marks' in an image

Post by pitosalas »

re: http://www.salas.com/elect/testballot1.tif

Please check out the image pointed to. Here's what I need to do:

Notice that along the top, bottom, left and right there are a series of black rectangles which I call timing marks.

I would like to identify the coordinates of each one of them. What I need is the top left corner.

The rectangles are not all exactly the same size but they are all clearly different from what's around them. They are approximately 38x15 pixels each. The image is black and white.

I tried looping through with img.find_similar_region, starting the search at 0,0 and then continuing it at the found pixel + 1 in each direction. I used a 38x15 image to compare. It found only a few timing marks.

Then I tried making the target black rectangle smaller and smaller, and it found more and more timing marks, but never all of them. And it started finding more and more false positives.

This is probably not the right technique...

Ideas?

Thanks!

Pito
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: locating 'timing marks' in an image

Post by anthony »

I would take a single column of pixels that goes through all the timing marks.
this would produce a 'profile' or 'graph' of ON/OFF values though may have some
grey values on the edges.

All that you now need to do is to cycle though the list and find the on/off transitions,
and maybe work out a 'center' for each black region (preferably to a sub-pixel quality.
From this you can work out a average' rate or distance between the points.

Now exactly what you want will depend on exactly what you need the marks locations for.


Judging from the image, I say you plan to use the marks to 'locate' the filled in marks.
Please report back an let us know what you finally come up with.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
pitosalas

Re: locating 'timing marks' in an image

Post by pitosalas »

Good guess :)

Now... What do you suggest re the 'image format'? In other words, this tif is black and white. But when I cycle through the pixels (I am using RMagick but I think it's all the same) each pixel shows an R,G, and B value.

Should I convert the whole thing to an array of short ints that are either 1 or 0 to make processing faster?

Is there an IM way of working as fast as possible through a B*W image?

Thanks!

Pito
pitosalas

Re: locating 'timing marks' in an image

Post by pitosalas »

Oh also... are there IM primitives that do things like

"from position x,y, locate the first white to black boundary on the left"
... "on the right"
... "above"
... "below"

In other words, as I am traversing this image in memory by iterating through pixels, interspersed with lots of method calls, I am thinking, there's probably some super fast low level methods to doing that?

Thanks!!

Pito
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: locating 'timing marks' in an image

Post by anthony »

no primitives like that, at least not in normal IM library (maybe in RMagick)

As the image is basically gray scale, ensure it is grey scale, and just look at ANY color channel. For grayscale image all channels are the same value. Actually if you do that you can clear the other channels, and use them to generate masks or other marks on your image.

On thing you may like to do is blur and threshold one copy of the image so as to reduce the influence of text and lines, and highlight the dots and spots you are actually looking for.

So if you can then find a 'dot' in a particular region, then the user marked it. Otherwise they didn't.

the side 'dots' would in that can only be used to align the image with out pre-preprepared masks.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
jaffamuffin
Posts: 59
Joined: 2009-01-30T03:46:08-07:00

Re: locating 'timing marks' in an image

Post by jaffamuffin »

This link may be useful for processing the 'filled in marks', as I was form processing some things...
pitosalas

Re: locating 'timing marks' in an image

Post by pitosalas »

Jeff, I don't see the link you refer to. Did you leave em out by mistake? Thanks,

Pito
jaffamuffin
Posts: 59
Joined: 2009-01-30T03:46:08-07:00

Re: locating 'timing marks' in an image

Post by jaffamuffin »

pitosalas wrote:Jeff, I don't see the link you refer to. Did you leave em out by mistake? Thanks,

Pito
whooops

viewtopic.php?t=13064
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: locating 'timing marks' in an image

Post by anthony »

FYI: implementation of morphological operators for discussion by developers.

viewtopic.php?f=2&t=13914&p=47625#p47625
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply