After noise reduction, my array is this one:
[[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]]
And after trying to invert it with 1-array I still obtain a blue output
After noise reduction, my array is this one:
[[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]]
And after trying to invert it with 1-array I still obtain a blue output
You are probably getting a blue image because the default colormap
is jet
. One of the end-members of jet
is blue, hence you get a blue image. You can see the colormaps reference page here.
You can change the colormap of your image with the cmap
kwarg. For example, for a monochrome image:
plt.imshow(image_array,cmap='Greys')
You may also need/want to set the limits of the image array so that the colours/shades correspond correctly with the colormap:
plt.imshow(image_array,cmap='Greys',vmin=0,vmax=1)
You can find a description of how to use images under http://matplotlib.org/users/image_tutorial.html.
Basically, matplotlib accepts normalized arrays, i.e. with values between 0 and 1. For your image data, this means that you have to divide it by 255.
An example would be
normalized_image = np.load('testing.npy') / 255.
plt.imshow(normalized_image)
Or the following for an inverted image
plt.imshow(1 - normalized_image)
For a black and white image, you could use the solution given in Plot a black-and-white binary map in matplotlib:
plt.imshow(1 - normalized_image, cmap="Greys")