What i mean that:
- I expect to see blank black image when i create image using np.ones which i see that result.
- I expect to see black and white mixed image when i create random array consist either 0 or 1 which i see that result.
- I expect to see blank white image when i create image using np.zeros which i still see blank black image.
Here are my codes:
def display_img(img):
fig = plt.figure(figsize=(12,10))
ax = fig.add_subplot(111)
ax.imshow(img,cmap='gray')
1.) Below code gives black image as expected.
black = np.zeros((600,600),dtype=np.int8)
black
display_img(black)
array([[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]], dtype=int8)
2.) Below code gives mixed image black image with white noises as expected since some values are 1 now.
white_noise = np.random.randint(low=0,high=2,size=(600,600))
white_noise
display_img(white_noise)
array([[0, 1, 1, ..., 0, 1, 0],
[1, 0, 1, ..., 1, 0, 0],
[0, 1, 0, ..., 0, 0, 1],
...,
[1, 1, 1, ..., 0, 0, 1],
[0, 1, 1, ..., 0, 1, 0],
[0, 0, 0, ..., 0, 1, 0]])
3.) Below code gives black image but i expect to see white
white = np.ones((600,600),dtype=np.int8)
white
white
array([[1, 1, 1, ..., 1, 1, 1],
[1, 1, 1, ..., 1, 1, 1],
[1, 1, 1, ..., 1, 1, 1],
...,
[1, 1, 1, ..., 1, 1, 1],
[1, 1, 1, ..., 1, 1, 1],
[1, 1, 1, ..., 1, 1, 1]], dtype=int8)
display_img(white)