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
Release history Release notifications | RSS feed
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)