How to integrate discrete values over a known x, y coordinate image

I know a digital image f (x, y), and the corresponding power spectrum is obtained by Fourier transform, but I need to request the integration of the power spectrum in an annular area, I want to use integral2 It is, but I only have the value of f (x, y) and the coordinate value (x, y), I do n’t know how to use double integration。
ps:the power spectrum like this
and I want to integrate the power spectrum in an annular region like this
and the integral is
is the power spectrum of the image f(x,y)(A random image),and i calculate it by this
I=fftshift(ft2(image);
s_power = abs(I).^2;
But s_powers is (x, y) coordinate, I could not calculate its double integral, ask for help!SOS!

4 Comments

I used to multiply the an annular mask by s_power,ps:1 in the annular area and 0 in other areas
temp = mask.*s_power;
r = sum(sum(temp));
and use r as a result,however,maybe it is not ture。
Don't send me direct e-mail as you did, asking me to answer your question. You should have gotten that hint from my profile, the way you did manage to contact me. It specifically asks people not to contract me. If I respond to it, then you learn to pester me for every future question you have about MATLAB or mathematics. That then forces me to add your name to mail filters to delete any future mail from you - now done. So this is now the only time I will respond to you.
I will only say you cannot just use integral/integral2 on an image, or any set of data. A function is required for those tools. Regardless, integral is not the proper tool to integrate a noisy surface, as it would try to chase every bump in the noise. Instead, consider what rectangle rule is, when used on a surface. Don't forget that for a true integral, you must multiply by the area of each element.
I'm sorry to bother you, but I didn't see your homepage prompt when I emailed you. I'm too anxious to solve this problem. I'm sorry to trouble you. I'm very sorry. I didn't intend to disturb you, but I found your answer very helpful. I sincerely beg your forgiveness. I really need your help, sorry to bring you a bad mood
I am so sad,I really didn't mean it.I found a question you answered very useful, so I am too eager to ask you, so that I did not click on your personal homepage, I am really sorry, it is indeed my fault, hope you forgive me.

Sign in to comment.

 Accepted Answer

Here is the idea
% calculate increments
dx = x(2)-x(1);
dy = y(2)-y(1);
% assume A is your image
% assume X and Y are your 2d matrices of coordinates
R = hypot(X,Y); % calculate radius
ix = r1 <= R & R <= r2; % boundaries of integration
A1 = A*0; % preallocation
A1(ix) = A(ix); % region of interest
S = 0;
for i = 1:size(A1,1)
for j = 1:size(A1,2)
s = A1(i:i+1,j:j+1); % 4 neigbour values
S = S + sum(s(:)); % sum values
end
end
S = S*dx*dy/4; % value of integral

3 Comments

First of all, I sincerely thank you for your reply.But I still have some questions,
first,Should the value range of i be narrowed
for i = 1:size(A1,1)-1
for j = 1:size(A1,2)-1
s = A1(i:i+1,j:j+1); % 4 neigbour values
S = S + sum(s(:)); % sum values
end
end
Otherwise it will exceed the matrix size of A1
second,Do you mean to convert continuous integrals into discrete integral sums?But I don’t understand why you add four adjacent values,you finally divide 4
s = A1(i:i+1,j:j+1); % 4 neigbour values
S = S + sum(s(:)); % sum values
Can you help me answer my doubts?
You are calculating volume under the the surface
Volume is average height and dx,dy:
I forgot to add this line. It's because you have a complicated shape, you have to sum only nonzero values
s = A1(i:i+1,j:j+1); % 4 neigbour values
if all(s(:))
S = S + sum(s(:)); % sum values
end
Little explanation
Thank you very much. I appreciate your answer!

Sign in to comment.

More Answers (0)

Products

Asked:

on 13 May 2020

Commented:

on 15 May 2020

Community Treasure Hunt

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

Start Hunting!