Exploration14

.m

School

Georgia Institute Of Technology *

*We aren’t endorsed by this school

Course

1554

Subject

Computer Science

Date

Dec 6, 2023

Type

m

Pages

2

Uploaded by PresidentMoon12744

Report
clc % Clear the command window RGB = imread('buzz.jpeg'); % Read the image file 'buzz.jpg' into MATLAB gray = rgb2gray(RGB); % Convert the RGB image to grayscale A = im2double(gray); % Convert the grayscale image to double precision for processing [U,S,V] = svd(A); % Perform Singular Value Decomposition (SVD) on the image matrix A. % U, S, and V are the matrices resulting from the decomposition sz = size(A); % Get the size of the original image matrix A Approx = zeros(sz); % Initialize a matrix to store the approximation of the original image r = 10; % Set the rank for the approximation. This can be changed to see different results for i = 1:r u = U(:,i); s = S(i,i); v = V(:,i); Approx = Approx + s*u*v'; % Reconstruct the image using only the first r singular values. % This loop adds the contribution of each singular value to the approximation end Approx; % The final approximate image matrix subplot(1,2,1), imshow(A), title('original'); % Display the original image subplot(1,2,2), imshow(Approx), title(['low rank r=', num2str(r)]); % Display the approximated image with the current value of r % Question: Why is it important that the image file is converted to grayscale? % Answer: Converting to grayscale is important because SVD operates on 2D matrices. % This process reduces a 3D color image (RGB layers) to a single 2D matrix, simplifying the SVD application and making it computationally feasible. % Question: What is the practical effect of having a low r-value? % Answer: A low r-value results in a lower rank approximation of the image, leading to reduced detail and clarity. % The image becomes blurrier and less detailed as fewer singular values are used to approximate the original image matrix. % Question: Compute the Approx matrix for r = 10 and then compute the rank of the matrix Approx. Do this for several more r-values. What do you notice? % Observation: As the r-value decreases, the rank of the Approx matrix also decreases, resulting in an image with less detail and clarity.
% This shows the trade-off between the amount of data (singular values) used and the fidelity of the image approximation. % Question: State a small r-value that still results in a clear image, explain why such a clear image can be obtained from a low rank image matrix. % Answer: A small r-value, such as 30, can still result in a clear image. This is because the most significant singular values capture the crucial features of the image. % Even with a lower rank, these key features can be retained, showing the efficiency of SVD in capturing the essence of the image with less data. % Optional Question: Can the process be modified to deal with color images? % Optional Answer: Yes, the process can be adapted for color images by applying SVD separately to each color channel (Red, Green, Blue) and then combining the approximations of these channels. % This approach allows for color image compression while preserving the core characteristics of the original image.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help