I have an image of a black paper cut in a right angled traingle shape and placed on a sheet of white paper. Size of the image is 100x100 pixels. The triangle looks and has the dimensions as shown below. /| / | / | B b = length of side A / | h = length of side B /__| A

The region inside the trianlge is black (gray value of pixels might not be exactly 0's for all the pixels. It varies from pixels to pixel.) and region outside the triangle has pixels with gray value =

255. By physics, i know that the center of gravity of this traingle should lie inside the triangle at a distance of b/3 to the left of side B and at h/3 above side A.

How can I get to this CG point, which will be a function of gray scale value and pixel location, by taking image as input?

My search on internet lead me to this:

formatting link
The link provides me with some hint to my problem except for the fact that brighter pixels will exert more pull on the final COG location than darker pixels. I want the exactly opposite of this i.e( I need more pull from dark pixels). I dont want to thershold the image.

Any idea how I can do this?

Regards, Vishwas

Reply to
Loading thread data ...

Simply average up the position of all the black pixels. Or, as a slight refinement, compute a weighted average using the "blackness" of each pixel as the weight.

You'll find the subtraction operator (-) useful for fixing that.


- Joe

Reply to
Joe Strout

Thanks Joe. I was able to get it.


Reply to

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.