Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #importing some useful packages
- import matplotlib.pyplot as plt
- import matplotlib.image as mpimg
- import numpy as np
- import cv2
- from scipy import ndimage, misc
- %matplotlib inline
- import math
- from skimage import img_as_ubyte
- def grayscale(img):
- img=cv2.imread('test_images/solidWhiteRight.jpg')
- img=img_as_ubyte(img)
- """Applies the Grayscale transform
- This will return an image with only one color channel
- but NOTE: to see the returned image as grayscale
- (assuming your grayscaled image is called 'gray')
- you should call plt.imshow(gray, cmap='gray')"""
- #return np.dot(img[...,:3], [0.299, 0.587, 0.114])
- #return cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
- # Or use BGR2GRAY if you read an image with cv2.imread()
- return cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
- gr=grayscale(img)
- print (gr.dtype)
- gr=np.zeros ((...,...,3))
- #plt.imshow(gr,cmap = plt.get_cmap('gray'))
- plt.imshow(gr)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement