How can I find exactly the coordinates of the center of the yellow circle?
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi everybody,
maybe my problem is stupid, but I need your help. I need to find exactly the center of the yellow circle in my image. It's an electromagnetic field distribution and I need to know whwre is centered, because it's not in the center of the image. Is there a way to find it out? I'm working with a 601x601x13 double matrix, I plotted the distribution at a certain height along the Z axis. Thanks to anyone who will give me a hand.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/618998/image.jpeg)
댓글 수: 4
채택된 답변
Walter Roberson
2021년 5월 15일
편집: Image Analyst
2021년 5월 15일
You can calculate the center of mass of the image.
댓글 수: 7
Walter Roberson
2021년 5월 16일
Experimenting:
format long g
rvec = linspace(-5,5,100);
cvec = linspace(-5,5,100);
[r, c] = ndgrid(rvec, cvec);
actual_center = randn(1,2)
A = 10 .* exp(-(r-actual_center(1)).^2/2) .* exp(-(c-actual_center(2)).^2/2);
pcolor(r, c, A)
ideal_array_r = interp1(rvec, 1:length(rvec), actual_center(1))
ideal_array_c = interp1(cvec, 1:length(cvec), actual_center(2))
tot_mass = sum(A(:));
[ii,jj] = ndgrid(1:size(A,1),1:size(A,2));
R = sum(ii(:).*A(:))/tot_mass;
C = sum(jj(:).*A(:))/tot_mass;
out = [tot_mass,R,C]
calculated_array_r = R
calcualted_array_c = C
So that is actual 61.5628526804514 versus calculated 61.5608654718254 and actual 26.4853227796535 versus calculated 26.6115951119575
Accuracy in the first case was about 1/100 which is less than 1 / number of bins in that direction.
Accuracy in the second case was about 13/100 which is notably less precise.
This hints that the accuracy can depend upon how close to the edge of the image that you are, in cases where data is being effectively truncated. This makes sense from a mathematical perspective.
추가 답변 (2개)
Rakesh Das
2021년 5월 15일
circle is (x – h)2+ (y – k)2 = r2, where (h, k) represents the coordinates of the center of the circle, and r represents the radius of the circle. If a circle is tangent to the x-axis at (3,0), this means it touches the x-axis at that point. this is the concept of obtating the coordinates of yellow circle.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Number Theory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!