Tradutor

quinta-feira, 21 de janeiro de 2016

# Numpy Hints

" usr/bin/env python"
"-*- coding:utf-8 -*-"
# This simple code shows how to create an
 array and an image with theses arrays

# importing numpy module as np
import numpy as np

#from matplotlib module importing pyplot submodule as plt
from matplotlib import pyplot as plt

# creating an array using np reference
one_array = np.array([1,15])

# creating images
image0 = np.linspace(0, 27, 10000).reshape(100,100)

# atributting data-type uint8, commonly used in image processing 
image1 = np.linspace(0, 255, 10000).reshape(100,100).astype(np.uint8)

# showing the data types, min and max
print("Image0:", image0.dtype, image0.min() , image0.max())
print("Image1:", image1.dtype, image1.min() , image1.max())

# creating a figure object
fig,  (ax0, ax1) = plt.subplots(1,2)

# add image0 to axes 0
ax0.imshow(imagem0, cmap='gray')

# add image1 to axes 1 
ax1.imshow(image1, cmap='winter')

# shows images
plt.show()

Nenhum comentário:

Postar um comentário