Filter löschen
Filter löschen

Converting an image using radial profile

8 Ansichten (letzte 30 Tage)
Minseo Jeong
Minseo Jeong am 21 Feb. 2022
Beantwortet: Simon Chan am 21 Feb. 2022
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?

Antworten (1)

Simon Chan
Simon Chan am 21 Feb. 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');

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by