Page 1 of 1
locating 'timing marks' in an image
Posted: 2009-06-01T17:50:27-07:00
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
Re: locating 'timing marks' in an image
Posted: 2009-06-01T18:10:52-07:00
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.
Re: locating 'timing marks' in an image
Posted: 2009-06-01T18:26:05-07:00
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
Re: locating 'timing marks' in an image
Posted: 2009-06-01T18:28:50-07:00
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
Re: locating 'timing marks' in an image
Posted: 2009-06-01T18:46:21-07:00
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.
Re: locating 'timing marks' in an image
Posted: 2009-06-04T05:49:00-07:00
by jaffamuffin
This link may be useful for processing the 'filled in marks', as I was form processing some things...
Re: locating 'timing marks' in an image
Posted: 2009-06-04T06:23:54-07:00
by pitosalas
Jeff, I don't see the link you refer to. Did you leave em out by mistake? Thanks,
Pito
Re: locating 'timing marks' in an image
Posted: 2009-06-04T06:25:03-07:00
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
Re: locating 'timing marks' in an image
Posted: 2009-06-04T18:20:35-07:00
by anthony
FYI: implementation of morphological operators for discussion by developers.
viewtopic.php?f=2&t=13914&p=47625#p47625