Image rotation is an increasingly commonly used feature in many smart-phone image apps.
In this problem, you will create an implementation of image rotation based on user input
in MATLAB.
Draft a flowchart for this task and save it as
ma4_ind_username.pdf.
Open the
ENGR133_MATLAB_UDF_Template.mMATLAB template and complete the header information. Save your script as
ma4_ind_1_username.m.
Create a MATLAB program that reads
block.png image file and
outputs the image to the screen as Figure 1 using the imshow command.
Properly label this image as “Color Original Image”.
imread returns an array of row X column X frames. The number of frames for
a colored image is generally ‘3’ (RGB) or ‘5’. Convert the image into a grayscale
image using the built-in MATLAB function rgb2gray. Output the
image to the screen as Figure 2 and label it as “Grayscale Original Image”
Use menu function to ask the user to choose either the colored original
image or grayscale image.
Use menu function again to ask the user to select a flipping direction for
the image they have chosen above.
ma4_ind_1_vertical_username.m,
which flips the image vertically (i.e. over a horizontal line that runs through
the center of the image). Use only nested for loops to rotate the image.
ma4_ind_1_horizontal_username.m,
which flips the image horizontally (i.e. over a vertical line that runs through
the center of the image). Use only nested for loops to rotate the image.
ma4_ind_1_diagonal_username.m,
flips the image over a diagonal line that runs from the top left to the bottom
right of the image. Use either nested loops or transpose/permute to rotate the
image. permute can be used to rearrange the dimensions of a
multidimensional array.
Publish each of your UDF scripts as
ma4_ind_1_vertical_username.pdf,
ma4_ind_1_horizontal_username.pdf,
and
ma4_ind_1_diagonal_username.pdf.
Note
MATLAB will produce an error if you try to publish a script that
requires user input.
Thus, we need to update our publishing option accordingly:
Click on down arrow button and select Edit Publishing Option.
Under MATLAB expression, write down the appropriate input.
Output the rotated image to the screen as Figure 3 and label the output “Image
Flipped XX” where XX indicates the selection by the user (vertical, horizonal, or
diagonal).
Publish ma4_ind_1_username.m as a PDF
using one of the test cases and name it
ma4_ind_1_username.pdf.