1. 2D transformation matrix Develop a MATLAB function called rotateAboutCenterImage that calculates the 2D transformatio
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
1. 2D transformation matrix Develop a MATLAB function called rotateAboutCenterImage that calculates the 2D transformatio
1. 2D transformation matrixDevelop a MATLAB function called rotateAboutCenterImage thatcalculates the 2D transformation matrix that rotates an image aboutits center (center = width/2, height/2). The function inputs areimage width, image height, and rotation angle. The function outputis the 2D transformation matrix. Include the numerical resultsoutput of the function rotateAboutCenterImage with image width =320, image height = 240, and rotation angle = π/6 in your reportwith sufficient precision such that it can be evaluated (hint: useformat shortg in MATLAB prior to displaying your results).2. Image transformation and interpolationI. Nearest neighbor interpolationDevelop a MATLAB function called rotateImageNearestNeighbor thattransforms an image using the nearest neighbor interpolationmethod. The function inputs are an image and a 2D transformationmatrix. The function output is the transformed image. The functionmust set pixels to black in the output image that inversely map topixels outside of the input image boundaries.Develop a MATLAB script called hw1_nearest_neighbor.m that usesimread to read the input image cameraman.tif (included withMATLAB); rotates the image about the center at rotation angles π/6,π/4, and π/2; and writes the corresponding output images tocameraman_nearest_neighbor_rot30.png,cameraman_nearest_neighbor_rot45.png, andcameraman_nearest_neighbor_rot90.png. The script must call thefunction rotateAboutCenterImage to calculate each 2D transformationmatrix (hint: use the size function to determine the width andheight of the image). The script must call the functionrotateImageNearestNeighbor to apply the transformation. Use imwriteto write each output image in MATLAB. Include in your report theinput image and the output image for each rotation angle.II. Linear interpolationDevelop a MATLAB function called rotateImageLinear that transformsan image using the linear interpolation method. The function inputsare an image and a 2D transformation matrix. The function output isthe transformed image. The function must set pixels to black in theoutput image that inversely map to pixels outside of the inputimage boundaries.Develop a MATLAB script called hw1_linear.m that uses imread toread the input image cameraman.tif; rotates the image about thecenter at rotation angles π/6, π/4, and π/2; and writes thecorresponding output images to cameraman_linear_rot30.png,cameraman_linear_rot45.png, and cameraman_linear_rot90.png. Thescript must call the function rotateAboutCenterImage to calculateeach 2D transformation matrix (hint: use the size function todetermine the width and height of the image). The script must callthe function rotateImageLinear to apply the transformation. Useimwrite to write each output image in MATLAB. Include in yourreport the output image for each rotation angle. Comment on thequalitative differences between these results and those obtainedusing nearest neighbor interpolation.