Finding a centroid of an area ( y coord. ) under discrete valued 2D function
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Doug Hull
2011-11-14
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!