create script.py

This commit is contained in:
Murat Onur Yildirim 2022-10-04 12:34:34 +02:00 committed by GitHub
parent b7be4bcc7f
commit 727cf6b2b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,11 @@
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
def rgb2gray(png_file='file_example.png'):
img = mpimg.imread(png_file)
gray = np.dot(img[:,:,:3], [0.2989, 0.5870, 0.1140])
plt.imshow(gray, cmap=plt.get_cmap('gray'), vmin=0, vmax=1)
plt.axis('off')
plt.savefig('gray_' + png_file + '.png', dpi=300)