Re: how to calculate centroid for non-constant desity polygon



To do it numerically, first create your polygon in an array with the
exponential values for the elements. Then....
To find the x centroid, just use sum(v*x)/sum(x).
To find the y centroid, just use sum(v*y)/sum(y).
v is the exponential formula you gave. Calculate the sum over ALL
array elements, in both the x and y directions, to get either of the
centroids.
If you have the image processing toolkit, just threshold, use bwlabel
() and then use regionprops(). Be sure to pass in your original
image, as well as your thresholded image (which specifies which pixels
contain the polygon) into regionprops().

You can compare your numerical answer with the analytical answer which
you can probably find in a book on calculus or statistics. If you
need more accuracy, just make your array bigger.
Regards,
ImageAnalyst
.



Relevant Pages

  • Re: Region composition?
    ... This array of points is ... into a region again you can use the ExtCreateRegionAPI call. ... If your polygon area's are likely to change API call) ... then it would be best IMO to store the polygon area's as a list of points and re-construct the region when necessary. ...
    (microsoft.public.vb.winapi.graphics)
  • Re: Region composition?
    ... This array of points ... > polygon section, but does mean they're not quite as flexible as a vector ... > handle use the GetRegionDataAPI call which will return you a RGNDATA ... and re-construct the region when necessary. ...
    (microsoft.public.vb.winapi.graphics)
  • Re: multiple polygons on one image
    ... (An array is defined ... // fill the background color ... // choose a color for the polygon ... // draw the second polygon ...
    (comp.lang.php)
  • Array Construction
    ... I would like to build an array of points that lie ... within a polygon as it moves across a plot. ... loop (while within certain plot parameters). ... messy and open to repetitive counting. ...
    (comp.soft-sys.matlab)
  • Re: How to judge a point in a region?
    ... And I must judge all the ... > But to create the array, I must call PtInRegion so many times. ... get the minimum x,y and maximum x,y of your polygon then: ...
    (microsoft.public.vc.mfc)