Converting and Translating Points From Azimuth and Elevation to a Sphere and Back

8 views (last 30 days)
transformedImage = app.originalImage; % Original image is the image to be translated
transformedImage(:, :, :) = 0; % Creating a blacnk image to map pixels to
length = app.imageLength;
width = app.imageWidth;
% loop through every pixel in the image
for i = 1 : 1 : width
for j = 1 : 1: length
% REFER TO FIGURE 1:
pixelAzimuth = (360/(length-1))*j + (-360/(length-1)-180); % Getting degrees azimuth from pixel position
pixelElevation = (-180/(width-1))*i + (180/(width-1)+90); % Getting degrees elevation from pixel position
% Generating 3D coordinates from the azimuth and elevation using math and translating the points
A = -pixelAzimuth+90;
E = -pixelElevation+90;
X = cosd(A) * sind(E + app.TotalPitch); % 360 image is to be rotated by TotalPitch degrees
Y = sind(A) * sind(E + app.TotalPitch); % 360 image is to be rotated by TotalPitch degrees
Z = cosd(E + app.TotalPitch);
% Getting azimuth and elevation back from X Y Z point
newAzimuth = acosd(Z);
newElevation = atan2d(Y, X);
% Translating azimuth and elevation back to pixel numbers
col = round(((1-length)/-360)*newAzimuth + -180*((1-length)/-360) + length);
row = round(((1-width)/180)*newElevation + 90*((1-width)/+180) + width);
% Map pixel from old image to transformed image with transformations
transformedImage(col, row, :) = app.originalImage(i, j, :);
end
end
% Set newImage property to the transformed image
app.newImage = transformedImage;
This is the code that is supposed to do the transformations. For some reason the col and row values generated are incorrect, and are causing errors.
FIGURE 1:
This is essentially what we are trying to do, translate the pixels in a 360 image along the blue line:

Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!