Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 5 . Write a function that accepts the name of an image file and an integer s . Use your function from Problem 3
Problem Write a function that accepts the name of an image file and an integer Use your function from Problem to compute the best ranks approximation of the image. Plot the original image and the approximation in separate subplots. In the figure title, report the difference in number of entries required to store the original image and the approximation use pltsuptitle Your function should be able to handle both grayscale and color images. Read the image in and check its dimensions to see if it is color or not. Grayscale images can be approximated directly since they are represented by dimensional arrays. For color images, let and be the matrices for the red, green, and blue layers of the image, respectively. Calculate the low rank approximations and separately, then put them together in a new dimensional array of the same shape as the original image. Hint: npdstack may be useful for putting the color layers back together. Finally, it is possible for the lowrank approximations to have values slightly outside the valid range of RGB values. Set any values outside of the interval to the closer of the two boundary values. Hint: fancy indexing or npclip may be useful here. To check, compressing hubblegray.jpg with a rank approximation should appear similar to Figure and save matrix entries.
Problem Write a function that accepts the name of an image file and an integer Use
your function from Problem to compute the best ranks approximation of the image. Plot
the original image and the approximation in separate subplots. In the figure title, report the
difference in number of entries required to store the original image and the approximation use
pltsuptitle
Your function should be able to handle both grayscale and color images. Read the image
in and check its dimensions to see if it is color or not. Grayscale images can be approximated
directly since they are represented by dimensional arrays. For color images, let and
be the matrices for the red, green, and blue layers of the image, respectively. Calculate the low
rank approximations and separately, then put them together in a new dimensional
array of the same shape as the original image.
Hint: npdstack may be useful for putting the color layers back together.
Finally, it is possible for the lowrank approximations to have values slightly outside the
valid range of RGB values. Set any values outside of the interval to the closer of the two
boundary values.
Hint: fancy indexing or npclip may be useful here.
To check, compressing hubblegray.jpg with a rank approximation should appear
similar to Figure and save matrix entries.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started