0

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

2 Answers 2

2

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)
Sign up to request clarification or add additional context in comments.

Comments

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")

2 Comments

I have edited my answer to include the inverting of the image.
still obtaining a blue-ish image

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.