A = imread('abcs.jpeg'); % b) Flipping images. Create a copy of A and then flip the image matrix % along the diagonal. Store your result in B. Do *NOT* use the flipup() or % fliplr() function. % % Write your code here: B = []; % d) Grayscale. Store the grayscale of the image matrix A in the variable % D. Use the simpler grayscale formula where the pixel value is the average % of the three layers. Do *NOT* use the weighted average formula or any % built-in MATLAB functions such as rgb2gray() or gray(). Note: First the % image matrix will need to by type double, and the final image needs to be % returned to uint8. % % Write your code here (it will be a few lines): D = []; %Both B and D should have a data type of uint8%
Added by Marcus M.
Close
Step 1
We can do this using a for loop and indexing the elements of the matrix. Here's the code: B = A; % create a copy of A for i = 1:size(A,1) for j = i:size(A,2) temp = B(i,j); B(i,j) = B(j,i); B(j,i) = temp; end end Show more…
Show all steps
Your feedback will help us improve your experience
Supreeta N and 66 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Create a 2x2 matrix with the elements {1, 2, 3, 4} using the matrix() function in R and store it in a variable A. Use rbind() on matrix A to add a row with elements {5, 6} and create a 3x2 matrix, which will be stored in B. Furthermore, use matrix B and add a column with elements {7, 8, 9} to it using cbind(). Display matrices A, B, and C.
Madhur L.
Sri K.
4 (25 points) Consider the following model for blurring images: Bij = 1/16 |i - j| = 2, 1/8 |i - j| = 1, 5/8 i = j, 0 otherwise. Additionally, assume the periodic boundaries of your image. Blur a matlab-provided demo image (e.g. mandrill.mat) applying the blurring iterations 16 times. Use GMRES algorithm to unblur the image. Use gmres matlab function. Restart the method every 60 iterations. Use the tolerance 10^-6. Plot the original image, the burred image, and the restored image side by side. Check whether the restored and the original image are the same (use matrix norms). If not, list (in the project's README file) possible reason(s) why they are different.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD