You have three transformation matrices below : % Set points A and B according to lab.pdf…
- User
You have three transformation matrices below :
% Set points A and B according to lab.pdf question A1 = [0 1 2 3; 0 1 2 3; 0 1 2 3]; B1 = [4 5 6 7; -5 -4 -3 -2; 6 7 8 9];
A2 = [1 2 3 4; 1 2 3 4; 1 2 3 4]; B2 = [1 2 3 4; 2 4 6 8; 3 6 9 12];
A3 = [5 3 4 2; 5 1 3 -1; 1 1 1 1]; B3 = [-1 1 0 2; 7 3 5 1; 1 1 1 1];
% Transformation matrices calculation T1 = B1 / A1; T2 = B2 / A2; T3 = B3 / A3;
Can you modify the program below to separately transform the image by the transformation matrices computed captured above?
im = double(imread('./smile.png'));
[row_im column_im] = size(im);
figure set (gcf,'Color',[1 1 1])
for x = 1:column_im for y = 1:row_im if im(y,x) == 255 plot3(x,y,1,'w.') grid on else plot3(x,y,1,'k.') end hold on drawnow end end
- Assistant
- User
the code above does not give the correct output. could you please try that code with 90 degree rotation in z-index for the T transformation matrix?
- Assistant
Sure, a 90-degree rotation around the z-axis in a 2D plane (assuming z is perpendicular to the x-y plane) is represented by the following 2D transformation matrix:
codecos(90) -sin(90) sin(90) cos(90)Since we are working with homogeneous coordinates to include translation in a 3x3 matrix for 2D transformations, the matrix looks like:
code[0 -1 0] [1 0 0] [0 0 1]The MATLAB code to apply a 90-degree rotation on the z-axis of each point of the image would be: