Converting an image using radial profile
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I want to obtain radial profiles of image (a) at 1 degree intervals from the center of circle. And then I want to arrange profiles by angle like image (c). The x-axis and y-axis of image (c) are angle and distance from the center of circle respectively. How should I do this?![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/901685/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/901685/image.jpeg)
0 comentarios
Respuestas (1)
Simon Chan
el 21 de Feb. de 2022
I don't have your original image and hence just crop a region as a demo.
You may change the variables according to your requirements:
Beware theta_start < theta_end and rho_start < rho_end.
Npoint is the number of points on each profile.
clear; clc;
rawdata = imread('imageA.jpg');
[Nu,Nx,Nc] = size(rawdata);
im = imbinarize(rawdata);
s0 = regionprops(im(:,:,1),'Centroid');
theta_start = -80; % theta_start < theta_end
theta_end = 0;
theta = (theta_start:1:theta_end)*pi/180;
Nprofile = length(theta);
rho_start = 20; % rho_start < rho_end
rho_end = 100;
[x_start,y_start] = pol2cart(theta,repelem(rho_start,1,Nprofile));
xs = x_start + s0.Centroid(1);
ys = y_start + s0.Centroid(2);
[x_end,y_end] = pol2cart(theta,repelem(rho_end,1,Nprofile));
xe = x_end + s0.Centroid(1);
ye = y_end + s0.Centroid(2);
Npoint = 80; % Number of points on each profile
profile = zeros(Npoint,Nc,Nprofile);
for k = 1:Nprofile
profile(:,:,k) = improfile(rawdata,[xs(k) xe(k)],[ys(k) ye(k)],Npoint);
end
display_profile = permute(flipud(profile), [1 3 2]);
figure(1)
subplot(1,2,1)
imshow(rawdata);
hold on
title('Image with profile start and end points');
plot(xs,ys,'b.');
plot(xe,ye,'r.');
subplot(1,2,2)
imshow(display_profile);
title('Extracted profiles');
0 comentarios
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!