|
On Sep 21, 11:08 am, "Mathew Thomas" <mathe...@gmail.com> wrote:
> Hello,
>
> I have a binary image with just one object in it. For example, two balls connected together... i want to find the shortest distance (go from row to row and find the row that has least number of white pixels in a line).
>
> Thanks in advance for any help
>
> Mathew
-----------------------------------------------------------------------------------------
Matthew:
Just sum horizontally with the sum() function:
verticalProfile = sum(binaryImage, 2);
Then use the min and find functions to find the index which is
minimum, something like (untested)
nonZeroIndexes = find(verticalProfile > 0)
minValue = min(verticalProfile(nonZeroIndexes))
minIndexes = (verticalProfile == minvalue)
Or something close to that - I didn't test the above code but
something like that should work.
Good luck,
ImageAnalyst
|