필터 지우기
필터 지우기

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

조회 수: 8 (최근 30일)
Pavl M.
Pavl M. 2011년 11월 14일
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

답변 (1개)

Doug Hull
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.
  댓글 수: 1
Pavl M.
Pavl M. 2011년 11월 15일
Hello Doug.Thank you for the answer , I've took a look at the .m files , -> yes you calculate centroid in several functions:
hortrap,rectube,tbeam,titleblock,twovector,vertrap,vertia.In next way:
xcentroid=hortrap(b,Origh,a,p,'centx');
ycentroid=hortrap(b,Origh,a,p,'centy');
xcentroid=rectube(ob,oh,ib,ih,'centx');
ycentroid=rectube(ob,oh,ib,ih,'centy');
It seems there are recoursive calls in all of the function to compute centroid. Also it seems you use there trapezoidal partition for integration. But I do not understand yet what is the algorithm for computing ycentroid from x = f(y) 2D discrete function samples ,how to find inverse y = f^-1(x) function from discrete samples there is no one to one mapping as in case of histogram , intergrational partition ? Thanks.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by