Numpy array only containing [0,0,0,1] when using imread on png file

144 Views Asked by At

Im using matplotlib and numpy to turn a png file (link to image: https://imgpile.com/i/boANTE) into a 2d array using this code:

import numpy as np
from matplotlib import pyplot as mat_plot

mapimage = mat_plot.imread("map.png")


print(mapimage)

when I run this the output looks like this

 [[0. 0. 0. 1.]
  [0. 0. 0. 1.]
  [0. 0. 0. 1.]
  ...
  [0. 0. 0. 1.]
  [0. 0. 0. 1.]
  [0. 0. 0. 1.]]

 [[0. 0. 0. 1.]
  [0. 0. 0. 1.]
  [0. 0. 0. 1.]
  ...
  [0. 0. 0. 1.]
  [0. 0. 0. 1.]
  [0. 0. 0. 1.]]

 [[0. 0. 0. 1.]
  [0. 0. 0. 1.]
  [0. 0. 0. 1.]
  ...
  [0. 0. 0. 1.]
  [0. 0. 0. 1.]
  [0. 0. 0. 1.]]]

I don't understand why this is happening as the png file contains coloured pixels but they are not being shown in the 2d array, even though when I open the image with matplotlib and hover over coloured pixels I can see that they should have rgb values other than 0,0,0.

0

There are 0 best solutions below