In [2]: I image.shape Out[2]: (300, 451, 3) Task 1: Converting from RGB to Gray Scale Image Create the gray scale image, represented by the 2D Numpy array image_gray from the RGB image tensor image...


python


In [2]:<br>I image.shape<br>Out[2]: (300, 451, 3)<br>Task 1: Converting from RGB to Gray Scale Image<br>Create the gray scale image, represented by the 2D Numpy array image_gray from the RGB image tensor image above.<br>To do this, for each pixel (i,j), you can use the formula<br>Yij = 0.2125 x R;j + 0.7154 × G¡j + 0.0721 × Bij,<br>where Y;; denotes the intensity of that pixel in gray scale image image_gray , and R;j, Gij, Bij denotes the intensity of that pixel in the RGB image<br>respectively.<br>Of course in your code you're encouraged to use array implementations/functions instead of looping through every pixel.<br>In [3]:<br>I # write your code to generate the array image_gray here<br>please rerun your code before submission<br># you can then use the following code to show the gray scale image<br>plt.imshow(image_gray,plt.get_cmap('gray'))<br>Out[3]: <matplotlib.image. AxesImage at Øx7f9706e43610><br>50<br>100<br>150<br>

Extracted text: In [2]: I image.shape Out[2]: (300, 451, 3) Task 1: Converting from RGB to Gray Scale Image Create the gray scale image, represented by the 2D Numpy array image_gray from the RGB image tensor image above. To do this, for each pixel (i,j), you can use the formula Yij = 0.2125 x R;j + 0.7154 × G¡j + 0.0721 × Bij, where Y;; denotes the intensity of that pixel in gray scale image image_gray , and R;j, Gij, Bij denotes the intensity of that pixel in the RGB image respectively. Of course in your code you're encouraged to use array implementations/functions instead of looping through every pixel. In [3]: I # write your code to generate the array image_gray here please rerun your code before submission # you can then use the following code to show the gray scale image plt.imshow(image_gray,plt.get_cmap('gray')) Out[3]: 50 100 150
Cjupyter homework_4 (autosaved)<br>Logout<br>File<br>Edit<br>View<br>Insert<br>Cell<br>Kernel<br>Widgets<br>Help<br>|Python 3 O<br>Not Trusted<br>Run I C »<br>Code<br>For this homework, you should write your code with basic Python or Numpy, and are not allowed to use any other packages/functions for image<br>processing or scientific computing.<br>Load the image<br>You can use the following codes to load the image. You're required to use this image throughout this homework.<br>In [1]:<br>I import numpy as np<br>import matplotlib.pyplot as plt<br>from skimage import data<br>image = data.chelsea()<br>plt.imshow (image)<br>Out[1]: <matplotlib.image. AxesImage at Ox1f87c4e87c0><br>50<br>100<br>150<br>200<br>250<br>100<br>200<br>300<br>400<br>image is a 3-d Numpy array, where the axis 0 and 1 correspdonds to 2D pixels, and axis 2 corresponds to RGB channels.<br>In [2]:<br>I image.shape<br>

Extracted text: Cjupyter homework_4 (autosaved) Logout File Edit View Insert Cell Kernel Widgets Help |Python 3 O Not Trusted Run I C » Code For this homework, you should write your code with basic Python or Numpy, and are not allowed to use any other packages/functions for image processing or scientific computing. Load the image You can use the following codes to load the image. You're required to use this image throughout this homework. In [1]: I import numpy as np import matplotlib.pyplot as plt from skimage import data image = data.chelsea() plt.imshow (image) Out[1]: 50 100 150 200 250 100 200 300 400 image is a 3-d Numpy array, where the axis 0 and 1 correspdonds to 2D pixels, and axis 2 corresponds to RGB channels. In [2]: I image.shape
Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here