From 727cf6b2b0093b610084711160bcfc6177e64e04 Mon Sep 17 00:00:00 2001 From: Murat Onur Yildirim Date: Tue, 4 Oct 2022 12:34:34 +0200 Subject: [PATCH 1/2] create script.py --- scripts/rgb_to_grayscale/script.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 scripts/rgb_to_grayscale/script.py diff --git a/scripts/rgb_to_grayscale/script.py b/scripts/rgb_to_grayscale/script.py new file mode 100644 index 0000000..46ddaf4 --- /dev/null +++ b/scripts/rgb_to_grayscale/script.py @@ -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) From 714e48daef3f620061e2b7ec1e8defdb545d1d56 Mon Sep 17 00:00:00 2001 From: Murat Onur Yildirim Date: Tue, 4 Oct 2022 12:40:54 +0200 Subject: [PATCH 2/2] create readme.md --- scripts/rgb_to_grayscale/readme.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 scripts/rgb_to_grayscale/readme.md diff --git a/scripts/rgb_to_grayscale/readme.md b/scripts/rgb_to_grayscale/readme.md new file mode 100644 index 0000000..b135021 --- /dev/null +++ b/scripts/rgb_to_grayscale/readme.md @@ -0,0 +1,10 @@ +# RGB to Grayscale Images + +This simple script converts RGB .png files to Grayscale .png files. + +## Usage + +Dependency: +- numpy +- matplotlib +- Use `pip install numpy and python` and `-m pip install -U matplotlib`