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

Thread Subject:
Finding center of the object

Subject: Finding center of the object

From: joveria

Date: 19 May, 2011 08:53:02

Message: 1 of 8

We have to find the centre of the object by xmin, xmax, ymax and ymin. Is there any function?
What the meaning of spikes and spur in matlab and how can we calculate them.

Subject: Finding center of the object

From: ImageAnalyst

Date: 19 May, 2011 10:08:08

Message: 2 of 8

On May 19, 4:53 am, "joveria " <capricon_ji...@yahoo.com> wrote:
> We have to find the centre of the object by xmin, xmax, ymax and ymin. Is there any function?
> What the meaning of spikes and spur in matlab and how can we calculate them.

---------------------------------------------------------
Use regionprops, as shown in my BlobsDemo image analysis tutorial:
http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

Subject: Finding center of the object

From: joveria

Date: 19 May, 2011 10:32:03

Message: 3 of 8

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <598f7a0d-9cc1-4702-8a05-d9ee6a5c655a@b42g2000yqi.googlegroups.com>...
> On May 19, 4:53 am, "joveria " <capricon_ji...@yahoo.com> wrote:
> > We have to find the centre of the object by xmin, xmax, ymax and ymin. Is there any function?
> > What the meaning of spikes and spur in matlab and how can we calculate them.
>
> ---------------------------------------------------------
> Use regionprops, as shown in my BlobsDemo image analysis tutorial:
> http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862


What other function is there to get the center of the object beside regionprops?

Subject: Finding center of the object

From: ImageAnalyst

Date: 19 May, 2011 10:39:24

Message: 4 of 8

You could use the well known math formulas
xCentroid = sum(x * value) / sum(value)

Do that for every pixel in the object. For binary image value = 1 so
xCentroid essentially means finding the mean x value for every line
and then taking the mean of that. You could also use find() to get
the coordinates that are non-zero, and then average them.

Subject: Finding center of the object

From: joveria

Date: 19 May, 2011 11:00:04

Message: 5 of 8

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <c63c14ab-5095-4f18-8ec1-7df3d5649850@24g2000yqk.googlegroups.com>...
> You could use the well known math formulas
> xCentroid = sum(x * value) / sum(value)
>
> Do that for every pixel in the object. For binary image value = 1 so
> xCentroid essentially means finding the mean x value for every line
> and then taking the mean of that. You could also use find() to get
> the coordinates that are non-zero, and then average them.


value of what?is it pixel value?

or is there any function to find max pixel values along x and y coordinates???

thanks in anticipation

Subject: Finding center of the object

From: ImageAnalyst

Date: 19 May, 2011 11:54:50

Message: 6 of 8

Yes. Value is the pixel value.
Please review the definition of weighted mean, which is what a
centroid is:
http://en.wikipedia.org/wiki/Weighted_mean

What you do depends on what you want. regionprops defines a centroid,
which is the location of the centroid of the binary image. It defined
"weighted centroid" as the centroid of the gray scale image masked by
the binary image. As you can imagine, if your blobs is not
symmetrical, the gray scale centroid may not be in the same location
as the binary image centroid (because the binary image has all the
same values 0s and 1s, not 0 through 256).

Your first message was very vague in that you didn't say if you wanted
the centroid of a binary image (logical values of true and false or 1
and 0), or the centroid of a grayscale image (values of 0, 1, 2, ...
255). So I gave you the general formula for a weighted mean which
will work with either - you just have to use the pixel values from the
image you're working on.

Subject: Finding center of the object

From: joveria

Date: 20 May, 2011 05:26:04

Message: 7 of 8

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <f8537856-7e25-4abc-b9f9-532651befa50@m10g2000yqd.googlegroups.com>...
> Yes. Value is the pixel value.
> Please review the definition of weighted mean, which is what a
> centroid is:
> http://en.wikipedia.org/wiki/Weighted_mean
>
> What you do depends on what you want. regionprops defines a centroid,
> which is the location of the centroid of the binary image. It defined
> "weighted centroid" as the centroid of the gray scale image masked by
> the binary image. As you can imagine, if your blobs is not
> symmetrical, the gray scale centroid may not be in the same location
> as the binary image centroid (because the binary image has all the
> same values 0s and 1s, not 0 through 256).
>
> Your first message was very vague in that you didn't say if you wanted
> the centroid of a binary image (logical values of true and false or 1
> and 0), or the centroid of a grayscale image (values of 0, 1, 2, ...
> 255). So I gave you the general formula for a weighted mean which
> will work with either - you just have to use the pixel values from the
> image you're working on.


We are new to image processing and having problems in understanding it.what is the function to see the detailed pixel values of binary image except imtool() and imview(). matlab command window cannot show all the information of image and i cannot analyse them.

Subject: Finding center of the object

From: ImageAnalyst

Date: 20 May, 2011 10:10:51

Message: 8 of 8

MATLAB's variable editor cannot show 3D (color) image values. Is that
what you're talking about? To see those you'd need to extract the
color channels and look at each one, one at a time.
redChannel = rgbImage(:,:,1);
greenChannel = rgbImage(:,:,2);
blueChannel = rgbImage(:,:,3);

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us