Efficient finding of locations where two 'on' pixels are next to one another [message #74361] |
Thu, 13 January 2011 09:28 |
Robin Wilson
Messages: 40 Registered: August 2010
|
Member |
|
|
Hi,
I'm working with a binary image which is the output of another procedure
I've run. I am trying to write a routine to post-process this image, and
clean it up a bit. As part of this, I want to find the indices of pixels
that are set to 1 (ie. 'on') that are next to other pixels that are set
to 1, but only in the X direction. To make that a bit clearer, there is
a diagram below:
(0) . . . * * . .
(1) . . . * . . .
(2) . . * * * . .
(3) . . . * . . .
(4) . . . * . . .
In this example I would want the indices of both 'on' pixels in Row 0,
nothing in Row 1 (as the pixel is not touching anything in the X
direction), all three in Row 2, and nothing in Rows 3 and 4.
At the moment all I can think of some kind of ghastly FOR loop with
loads of state-checking. I'm thinking that there must be a nicer (that
is more efficient and cleaner code) way...is there?
Cheers again,
Robin
|
|
|