Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Finding X and Y coordinates of a single white blob on a black background

Asked by David Bridges on 18 Sep 2013

I have a series of images which I need to find the x,y coordinates for a single white blob on black background. I would like coordinates to be taken from the center of the image. Thank you.

0 Comments

David Bridges

1 Answer

Answer by Image Analyst on 18 Sep 2013
Accepted answer

This is done by my BlobsDemo program. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862.

The blobs are the coins from the standard MATLAB demo image. It finds the centroids of all of them. You just need to subtract the number of rows and columns divided by 2 to get the coordinates referenced to a new coordinate system where the origin is in the middle of the picture.

6 Comments

David Bridges on 23 Sep 2013

Thanks, I have tried that but I cannot make it fit with your existing code. If you wouldn't mind a quick look, I have attached something that is looping already, but it only prints the centroids of the last jpg file in the folder. Files are virus-checked etc. Much appreciated!

Image Analyst on 23 Sep 2013

You have a loop that says

for j=1      

so of course it does only 1 image.

David Bridges on 24 Sep 2013

Finally figured it out, thanks for your help

Image Analyst

Contact us