Exploration14
.m
keyboard_arrow_up
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
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
Related Questions
#create a duplicate of the image
for y in range (image.getHeight()-1):
for x in range (1, image.getWidth () -1):
#Row major traversal of each pixel
#display in the image
oldPixel=image.getPixel(x,y)
#Get the pixel present at current place
leftPixel=image.getPixel(x-1,y)
#Get left pixel.
bottomPixel=image.getPixel (x, y+1)
#Get bottom pixel
oldLum-average (oldPixel)
#calcule luminance of current pixel
leftLum-average (leftPixel)
#calculate luminance of left pixel
bottomLum=average (bottomPixel)
#calculate luminance of right pixel
if abs (oldLum-leftLum) >threshold or\
abs (oldLum-bottomLum) >threshold:
new.setPixel (x,y, sharpen (old, degree))
return new
#3main function
def main ():
#Input image
image=Image ("testImage.gif")
image.draw ()
#Call the method, edge detection
out=edge_detection (image, 80,10)
out.draw ()
if
main ()
name
main
":
==
arrow_forward
Task 4: Write a Matlab code to do the following:
1. Read a "cameraman.tif image
2. Make the image smaller to [50, 50] and call it
small_img
3. Enlarge the output image from step 2 (small_img) into
[400, 400] using nearest neighbor interpolation.
4. Enlarge the output image from step 2 (small_img) into
[400, 400] using Bilinear interpolation.
arrow_forward
Please use Matlab for the question
arrow_forward
Q1- Assume that an image of 32x32 distributed as follows:
Gray level
12
14
15
16
18
19
20
21
22
Num of pixels
74
50
100
250
150
280
30
50
40
a) Draw the image histogram
b) Find the equalized histogram
arrow_forward
Implement an application that will compute and display the INTEGRAL image feed along with the stereo and RGB feed. You cannot use a built-in function such as
“output = integral_image(input)”
arrow_forward
no code is needed this is a hand written question
Question: You are given the following grays-scale image of size 2x2. Interpolate this image to size 3x3 using Bilinear Interpolation
100
200
80
60
arrow_forward
Build on our PBM image creator from (code shown below) to create a fully functional image editor (in C++), using 2D arrays to store our changes. To make it more interesting by switching to the Portable Gray Map standard. 8 bit PGM files have color values ranging from 0 (black) to 255 (white), with the values in-between being shades of gray. The header is very similar to PBM, and looks like this:
P2
WIDTH HEIGHT
255 IMAGE_DATA
The P2 tells image readers that it is a PGM file, and the 255 indicates the largest possible color value is 255.
You will first prompt the user to enter a width, height, and initial color value to fill the image. You should then create a 2D array with those dimensions and initialize each cell with that color value.
You will then use a loop to create a menu that repeatedly prompts the user to make one of the following choices:
Fill in a pixel with a new color
◦ Prompt the user to enter a row and column value and a new color value. If the array has that row and…
arrow_forward
Please use the Python languageUse filters for any image using kernel (filter) matrices. It should be done using loops (you can only use the image processing libraries to open or read the image). Apply these filters to an image you prefer with Python. Provide the outputs.
arrow_forward
4. Suppose there is a 4 * 4 image as shown below, if we reduce the image to 3 * 3 pixels, please
give the value of each pixel, and please give the calculation process of bilinear interpolation.
0 1 2 3
O 8 4 28
16 2 4 6
2 2 6 84
3 46 4 2
0 1 2
O ABC
1DEF
2 GH1
Y
arrow_forward
Computer Science
*/ JAVA
Compile and run the ImageGen01 application. Experiment with alternate formulas
for the value of c. Add two more int variables so that you can separately set the
RGB values of color and experiment some more. Share your most interesting re-
sults with your classmates.
arrow_forward
7.Do code complete"""You are given an n x n 2D mat representing an image.
Rotate the image by 90 degrees (clockwise).
Follow up:Could you do this in-place?"""
# clockwise rotate# first reverse up to down, then swap the symmetry# 1 2 3 7 8 9 7 4 1# 4 5 6 => 4 5 6 => 8 5 2# 7 8 9 1 2 3 9 6 3
def rotate(mat): if not mat: return mat mat.reverse() for i in range(len(mat)): for j in range(i): mat[i][j], mat[j][i] = mat[j][i], mat[i][j] return mat
if __name__ == "__main__": mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]].
arrow_forward
Using Python
Follow these steps to create your Warhol Grid:
Find or create an image (for this activity, a smaller starting image will produce higher quality results in a shorter amount of time).
Using the Python documentation as a guide, create a program that loads the image, filters three copies of it, and saves the result. Note: You will need to create the three filters using the filter() method.
Include multiple filters on at least two of your variants.
One of your variants must apply a single filter multiple times with the use of a loop. For example, the top right image above uses a loop to blur the image 2 times (what if we did it 100 times?).
One of your images must apply at least two different filters to the same image. In the example image, the bottom right image includes a a filter to smooth the image and then edge enhance them.
Create the Warhol Grid using Python with the three images you have created. You may modify and use the following starter code: Filters. to…
arrow_forward
Write a R Program output for below image.
arrow_forward
What color is color _rgb ( 0, 255 , 255) ?a) yellow b) cyan c) magenta d) orange
arrow_forward
Perform histogram equalization on the following 6*6 image the gray scalelevel distribution of the image is given below
arrow_forward
Q1: Rescale the following image to be 50% smaller than its original size (you should avoid Aliasing)
25
19
17
19
22
23
19
20
22
32
32
33
20
44
43
46
Q2: Rescale the following image to be 200% bigger than its original size using both
Nearest neighbor interpolation
BİLinear interpolation
25
17
19
19
22
32
arrow_forward
GIF is best suited for storing simple graphic images with relatively few colors?
False
True
arrow_forward
do the code by python with screenshot for code and output
Upload an image from your computer
Read that image
3- Calculate the histogram for that image
arrow_forward
Do fast.
arrow_forward
Read the sunspot data file and produce a scatter plot of os sunspot countsfrom 1849 to 2023. Use a marker size of one, and make the marker face and edge colors the same.Label the horizontal axis with years. Plot all the data points for every day from 1840 to 2023. Create the numbers for the horizontal axis by extracting the year from the lines inthe data file.
You can look at the peak finding example programs to see a use of scatter plots. This should be a fairly quick assignment. The next program will involve using the same sunspot data, appyingsmoothing, then finding and plotting the peaks and computing the period of the solar cycle.
arrow_forward
In octave, using a grayscale image how can you create a block matrix B so that the first 300 columns of the product C = AB are the last 300 columns of A and the last 212 columns of C are the first 212 columns of A.Then display the image C.
arrow_forward
This is a ------ mega pixels picture.
arrow_forward
Write a code and impelement one of the point processing techniques below. Use phython 3 /Jupyter Notebook. Please se nested loops to itterate through each indvidual pixel. the image file is in pgm format.
a. linear transformation
b. non linear trasformation
c. histogram genertion (the code should output the histogram data to an output file. You can then use an exisiting softeare such as excel to generate the histogram(bar chart)
d. Histogram equation
arrow_forward
Write a PYTHON program that can take any sort of image(jpeg, png, etc) as input from your computer and turn it into a DST/.dst image or file the program must have a gui and a button that says convert with a save button to save the dst file aswell
arrow_forward
- manufacturer: String
-width: double
-height: double
-horizontalPixels: double
-verticalPixels: double
DisplayPanel
+ DisplayPanel()
+ DisplayPanel(man: String, w: double, h: double, hp: double, vp: double)
+ setManufacturer(man: String): void
+ setWidth(w: double): void
+ setHeight(h: double) : void
+ setHorizontalPixels(hp: double): void
+ setVerticalPixels(vp: double): void
+ getManufacturer(): String
+getWidth(): double
+ getHeight(): double
+getHorizontalPixels(): double
+getVerticalPixels(): double
+diagonalSize(): double
+ pixelsPerinch(): double
+ totalPixels(): double
+toString(): String
The unit for height and width is inches.
The unit for horizontalPixels and
verticalPixels is pixels
diagonalSize()- The hypotenuse of the triangle
defined by the width and height. The unit of the
returned value is inches.
pixels Perinch() - Please see the linked resource
in the description for how to calculate this.
totalPixels()-The product of horizontalPixels and
vertical pixels. The unit…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
Related Questions
- #create a duplicate of the image for y in range (image.getHeight()-1): for x in range (1, image.getWidth () -1): #Row major traversal of each pixel #display in the image oldPixel=image.getPixel(x,y) #Get the pixel present at current place leftPixel=image.getPixel(x-1,y) #Get left pixel. bottomPixel=image.getPixel (x, y+1) #Get bottom pixel oldLum-average (oldPixel) #calcule luminance of current pixel leftLum-average (leftPixel) #calculate luminance of left pixel bottomLum=average (bottomPixel) #calculate luminance of right pixel if abs (oldLum-leftLum) >threshold or\ abs (oldLum-bottomLum) >threshold: new.setPixel (x,y, sharpen (old, degree)) return new #3main function def main (): #Input image image=Image ("testImage.gif") image.draw () #Call the method, edge detection out=edge_detection (image, 80,10) out.draw () if main () name main ": ==arrow_forwardTask 4: Write a Matlab code to do the following: 1. Read a "cameraman.tif image 2. Make the image smaller to [50, 50] and call it small_img 3. Enlarge the output image from step 2 (small_img) into [400, 400] using nearest neighbor interpolation. 4. Enlarge the output image from step 2 (small_img) into [400, 400] using Bilinear interpolation.arrow_forwardPlease use Matlab for the questionarrow_forward
- Q1- Assume that an image of 32x32 distributed as follows: Gray level 12 14 15 16 18 19 20 21 22 Num of pixels 74 50 100 250 150 280 30 50 40 a) Draw the image histogram b) Find the equalized histogramarrow_forwardImplement an application that will compute and display the INTEGRAL image feed along with the stereo and RGB feed. You cannot use a built-in function such as “output = integral_image(input)”arrow_forwardno code is needed this is a hand written question Question: You are given the following grays-scale image of size 2x2. Interpolate this image to size 3x3 using Bilinear Interpolation 100 200 80 60arrow_forward
- Build on our PBM image creator from (code shown below) to create a fully functional image editor (in C++), using 2D arrays to store our changes. To make it more interesting by switching to the Portable Gray Map standard. 8 bit PGM files have color values ranging from 0 (black) to 255 (white), with the values in-between being shades of gray. The header is very similar to PBM, and looks like this: P2 WIDTH HEIGHT 255 IMAGE_DATA The P2 tells image readers that it is a PGM file, and the 255 indicates the largest possible color value is 255. You will first prompt the user to enter a width, height, and initial color value to fill the image. You should then create a 2D array with those dimensions and initialize each cell with that color value. You will then use a loop to create a menu that repeatedly prompts the user to make one of the following choices: Fill in a pixel with a new color ◦ Prompt the user to enter a row and column value and a new color value. If the array has that row and…arrow_forwardPlease use the Python languageUse filters for any image using kernel (filter) matrices. It should be done using loops (you can only use the image processing libraries to open or read the image). Apply these filters to an image you prefer with Python. Provide the outputs.arrow_forward4. Suppose there is a 4 * 4 image as shown below, if we reduce the image to 3 * 3 pixels, please give the value of each pixel, and please give the calculation process of bilinear interpolation. 0 1 2 3 O 8 4 28 16 2 4 6 2 2 6 84 3 46 4 2 0 1 2 O ABC 1DEF 2 GH1 Yarrow_forward
- Computer Science */ JAVA Compile and run the ImageGen01 application. Experiment with alternate formulas for the value of c. Add two more int variables so that you can separately set the RGB values of color and experiment some more. Share your most interesting re- sults with your classmates.arrow_forward7.Do code complete"""You are given an n x n 2D mat representing an image. Rotate the image by 90 degrees (clockwise). Follow up:Could you do this in-place?""" # clockwise rotate# first reverse up to down, then swap the symmetry# 1 2 3 7 8 9 7 4 1# 4 5 6 => 4 5 6 => 8 5 2# 7 8 9 1 2 3 9 6 3 def rotate(mat): if not mat: return mat mat.reverse() for i in range(len(mat)): for j in range(i): mat[i][j], mat[j][i] = mat[j][i], mat[i][j] return mat if __name__ == "__main__": mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]].arrow_forwardUsing Python Follow these steps to create your Warhol Grid: Find or create an image (for this activity, a smaller starting image will produce higher quality results in a shorter amount of time). Using the Python documentation as a guide, create a program that loads the image, filters three copies of it, and saves the result. Note: You will need to create the three filters using the filter() method. Include multiple filters on at least two of your variants. One of your variants must apply a single filter multiple times with the use of a loop. For example, the top right image above uses a loop to blur the image 2 times (what if we did it 100 times?). One of your images must apply at least two different filters to the same image. In the example image, the bottom right image includes a a filter to smooth the image and then edge enhance them. Create the Warhol Grid using Python with the three images you have created. You may modify and use the following starter code: Filters. to…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningNew Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage Learning
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning