Question

In: Computer Science

MATLAB: Attempting to use the inverse mapping approach and take a 3x3 matrix that will rotate...

MATLAB:

Attempting to use the inverse mapping approach and take a 3x3 matrix that will rotate an image. The image is 540 x 420. attempting to write DOUBLE FOR LOOPS that will step through each and every pixel location. I cannot use any Toolbox Functions. Please write a double for loop that will allow this to happen!

[xold,yold,k] = size(A);

Rotation = [cosd(angle) -sind(angle) 0 ; sin(angle) cos(angle) 0; 0 0 1];

InverseRotation = double(inv(Rotation));

Solutions

Expert Solution

  • You're not multiplying the inverse rotation matrix by the image, you're multiplying it by the homogeneous coordinates of a point in the new image to get the corresponding homogeneous coordinates in the original image.

newpt = [xnew ynew 1].';
origpt = InverseRot*newpt;
xold = origpt(1);
yold = origpt(2);

  • Your rotation matrix mixes the degree and radian versions of the trig functions. That will mess up your results.
  • Rotations without translations are about the origin. Your image is not centered at the origin. You'll need to do something about that.
  • The inverse of a rotation matrix is the same as its transpose. If you fix the note above, you'll end up with an affine transformation matrix rather than a straight rotation matrix. This also has an easier way to calculate the inverse. If the affine transformation matrix is [R | t; 0 | 1], the inverse is [RT | -RT*t; 0 | 1] where RT is the transpose of R.
  • ​The coordinates in the original image that you get after transformation are not likely to be integers, so you won't be able to simply assign the value of a pixel in the old image to a pixel in the new image. As you said, you'll have to find some way to interpolate the value and assign that to the point in the new image.

Related Solutions

use matlab to create a function that finds inverse of 2x2 matrix and returns result. Should...
use matlab to create a function that finds inverse of 2x2 matrix and returns result. Should be a error check to make sure matrix is 2x2, and nonsingular.
Use this theorem to find the inverse of the given matrix or show that no inverse...
Use this theorem to find the inverse of the given matrix or show that no inverse exists. (If an answer does not exist, enter DNE in any cell.) 1    2    5    1 −1    0    2    1 2    1    −5    0 1    1    2    1
IN MATLAB, Create a 8x8 magic matrix. Then use MATLAB built in function, sum, to calculate...
IN MATLAB, Create a 8x8 magic matrix. Then use MATLAB built in function, sum, to calculate the sum of each column. Use subscript notation to find the 6th element and the last element of each magic square. Find the maximum of all the elements in each magic square.
Use the matrix inverse and the matrix division method to solve the following set for x and y in terms of c:
Use the matrix inverse and the matrix division method to solve the following set for x and y in terms of c:
Use MATLAB to plot the polynomials y = 3x4 - 6x3 + 8x2 + 4x + 90 and z = 3x3 + 5x2 - 8x + 70 over the interval -3 ≤ x ≤ 3.
Use MATLAB to plot the polynomials y = 3x4 - 6x3 + 8x2 + 4x + 90 and z = 3x3 + 5x2 - 8x + 70 over the interval -3 ≤ x ≤ 3. Properly label the plot and each curve. The variables y and z represent current in milliamperes; the variable x represents voltage in volts.  
MATLAB CODE: Making cubic spline iterpolation function. Then, To solve use Tridiagonal matrix algorithm(TDMA) xi -0.5...
MATLAB CODE: Making cubic spline iterpolation function. Then, To solve use Tridiagonal matrix algorithm(TDMA) xi -0.5 -0.4 -0.2 0 0.2 0.4 0.6 0.8 yi 0.04 0.1 0.4 1 0.35 0.2 0.3 0.04
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT