Finding a centroid of an area ( y coord. ) under discrete valued 2D function
5 views (last 30 days)
Show older comments
Hello,
I have a set of discrete pairs ( x , y ) - keys and values - 2D discrete function's samples - a histogram of input digital image that I need to process. ( y = f(x) )
I need to find y coordinate of a centroid of an area under a discrete 2D function ( histogram ) for special image processing after . I found next formulas for continues functions centroid: http://www.intmath.com/applications-integration/5-centroid-area.php
I've tried to calculate y coord. of a centroid using average method for discrete function integration but I'm not sure about computation of y , how to identify x = f-1(y) ( inverted ) and an intervals for computation in discrete case.
How to do that : from having (x,y) discrete pairs set to find the y coordinate of centroid of an area under the function y = f(x) for the given interval [a , b] ( size N )? I need pseudo code or C or Matlab code of calculation of the y:
something like ( pseudocode ):
function find_centroid ( map<Key,Value>input_hist ) returns int y;
Can anybody post a link for such problem solved , such function implemented or description of the algorithm ?
Thanks in advance
0 Comments
Answers (1)
Doug Hull
on 14 Nov 2011
I think I did something kinda similar to this in my book. The code is here.
It was for finding centroids of shapes made by compositing circles, rectangles and triangles.
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!