I had expected the following to create a new numpy array from the shape of an existing array but with modified element data type. My original array is an image with 8bit RGB pixels. I want to create a new array using same shape but with uint16 data type. The purpose is then to convert the image into 16bit pixels and perform some math. To my surprise the following didn't work.
>>> import scipy.misc as msc
>>> import numpy as np
>>> img_rgb = msc.imread('Jupiter_20160417_53.png')
>>> img_rgb.dtype
dtype('uint8')
>>> img_rgb.shape
(480, 640, 3)
>>> new= np.zeros(img_rgb.shape,dtype=uint16)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'uint16' is not defined
What did I miss?
Thanks, Gert