필터 지우기
필터 지우기

Average value of an annulus in a square matrix

조회 수: 1 (최근 30일)
matnewbie
matnewbie 2016년 5월 6일
편집: matnewbie 2016년 6월 18일
I have a square matrix of values and I need to evaluate the average value of an annulus between coordinates r and r+dr and repeat this step from the center of the circle to its radius R. Finally, I want to plot the radial profile of the N values, where N is the number of annuli.
How could I do this in MATLAB? Thank you in advance.

채택된 답변

Image Analyst
Image Analyst 2016년 5월 6일
편집: Image Analyst 2016년 5월 6일
So then take your ringPixels, which you get from the snippet in the FAQ, and then use mean to get the average value of your matrix within the ring:
meanValue = mean(yourImage(ringPixels))
By the way, I've attached a related thing. The demo computes the average radial profile (from a point you select) in an image and plots it.
  댓글 수: 1
matnewbie
matnewbie 2016년 6월 18일
편집: matnewbie 2016년 6월 18일
The script is ok, but I want to change two things:
  1. Zero values should not be taken into consideration when evaluating the profile.
  2. I want to obtain an overall radial profile on a 3D isotropic matrix (NxNxN) with center located at XCEN,YCEN and radius RAD. In this case I need to average the values on 3D annuli from 1 to RAD.

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

추가 답변 (1개)

Jos (10584)
Jos (10584) 2016년 5월 6일
R = 3 ;
M = magic(2*R+1) ;
dr = 1 ;
[ri,ci] = ndgrid(1:(2*R+1))
D = hypot(ri-R-1,ci-R-1)
for k=dr:dr:R
TF = D > (k-dr) & D <= k
tmp = M(TF)
Result(k) = mean(tmp)
end

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by