Import Numpy As Np Import Matplotlib Pyplot As Plt Load An Image I Plt Imread C

import numpy as np

import matplotlib.pyplot as plt

#load an image

I = plt.imread(‘C:UsersTinaDesktopimage.jpg’)

#display the shape of the array and data type


#convert to float data type and scale to [0..1] if necessary

if (I.dtype == np.uint8):

  I = I.astype(float) / 256

#I.dtype should now be float

#if your image is color (shape HxWx3), convert to grayscale by averaging together R,G,B values

R = np.array(img[:, :, 0])

G = np.array(img[:, :, 1])

B = np.array(img[:, :, 2])

R = (R *.299)

G = (G *.587)

B = (B *.114)


#display the image in the notebook using a grayscale colormap


#force matplotlib to go ahead and display the plot now  

#select out a 100×100 pixel subregion of the image

w,h = I.size

A = I.crop((w-50, h-50, w+50, h+50))

#display the selected subregion


I am not sure if I am doing this right.

Need your ASSIGNMENT done? Use our paper writing service to score good grades and meet your deadlines.

Order a Similar Paper Order a Different Paper