How to extract the radial profile in 'quarter' of circle?

5 visualizaciones (últimos 30 días)
Hi all,
I got an image which is a quarter of circle, and I want to extract the values in a curved line radially which center is a bottm right of the corner.
Here is the code for the radial profile. I modified a little bit of the radial profile code, which is posted in the Mathwork.
function profile = radialprofile(img)
[x y] = size(img2)
Z_integer=round(abs(x+1i*y/radial_step)+1);
end
How can I consider the fixed center position in the code?
Any suggestion and help is welcome. Thank you in advance. Haein

Respuesta aceptada

Bjorn Gustavsson
Bjorn Gustavsson el 15 de Mzo. de 2022
Think of this in cylindrical coordinates:
phi360 = linspace(0,2*pi,361);
r0 = [x_lower_right,y_lower_righth];
r = 12;
r_circ = [r*cos(phi360(:))+r0(1),r*sin(phi360(:))+r0(2)];
So that gives you coordinates on an entire circle;
To calculate the image-profile along a sector of that circle you can use interp2:
Im_sector = interp2(1:size(Im,2),1:size(Im,1),Im,r_circ(90:180,1),r_circ(90:180),'spline');
You might want to adjust any parts of this.
HTH

Más respuestas (1)

Simon Chan
Simon Chan el 15 de Mzo. de 2022
You may extarct the values of the radial profiles from variable 'display_profile' according to the code below.
It is a little bit long but allows you to define each parameter when extracting the profiles.
rawdata = imread('demo.png'); % Image
[Ny,Nx,Nc] = size(rawdata);
cx = Nx; % Define center of circle at the bottom right
cy = Ny; % Define center of circle at the bottom right
theta_start = -pi; % Profile starts at botton left
theta_end = -pi/2; % Profile ends at top right
Nprofile = 200; % Number of radial profiles
theta = linspace(theta_start,theta_end,Nprofile);
rho_start = 1150; % profile start at distance rho_start from circle center
rho_end = min(Nx,Ny); % profile end at distance rho_end from circle center
[x_start,y_start] = pol2cart(theta,repelem(rho_start,1,Nprofile));
xs = x_start + cx;
ys = y_start + cy;
[x_end,y_end] = pol2cart(theta,repelem(rho_end,1,Nprofile));
xe = x_end + cx;
ye = y_end + cy;
Npoint = 100; % Number of points on each radial profile
profile = zeros(Npoint,1,Nc,Nprofile); % Pre-allocate variable profile
for k = 1:Nprofile
profile(:,:,:,k) = improfile(rawdata,[xs(k) xe(k)],[ys(k) ye(k)],Npoint);
end
display_profile = permute(profile,[1 4 3 2]); % Re-arrange for displayed profile
figure(1)
subplot(1,2,1)
imshow(rawdata);
hold on
title('Image with profile start and end points');
plot(xs,ys,'b.'); % Blue dots represent profile start location
plot(xe,ye,'g.'); % Green dots represent profile end location
subplot(1,2,2)
imshow(display_profile);
title('Extracted profiles');

Community Treasure Hunt

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

Start Hunting!

Translated by