Skip to main content

rgb2gray

Project description

rgb2gray

Install

pip install rgb2gray

How to use

An example with rgb2gray

from PIL import Image
import matplotlib.pyplot as plt
result = rgb2gray(Image.new('RGB', (10, 10), color = (255,255,0)))
result
array([[226, 226, 226, 226, 226, 226, 226, 226, 226, 226],
       [226, 226, 226, 226, 226, 226, 226, 226, 226, 226],
       [226, 226, 226, 226, 226, 226, 226, 226, 226, 226],
       [226, 226, 226, 226, 226, 226, 226, 226, 226, 226],
       [226, 226, 226, 226, 226, 226, 226, 226, 226, 226],
       [226, 226, 226, 226, 226, 226, 226, 226, 226, 226],
       [226, 226, 226, 226, 226, 226, 226, 226, 226, 226],
       [226, 226, 226, 226, 226, 226, 226, 226, 226, 226],
       [226, 226, 226, 226, 226, 226, 226, 226, 226, 226],
       [226, 226, 226, 226, 226, 226, 226, 226, 226, 226]], dtype=uint8)
plt.imshow(result, cmap='gray')
plt.show();

img = Image.open('images/ds.jpg')
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(15,10))

axes[0].imshow(img)
axes[1].imshow(rgb2gray(img), cmap='gray')
plt.show();

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rgb2gray-0.0.4.tar.gz (7.7 kB view hashes)

Uploaded Source

Built Distribution

rgb2gray-0.0.4-py3-none-any.whl (7.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page