1 Attachment(s)

Finding centroid of a curve ( y coord. ) under discrete valued 2D function

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:

5. Centroid of an Area

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 a discrete function y = f(x) curve 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 ):

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 ,

my web site:

"R&D hardware . Computer/Embedded Systems Software"