1
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image 
import os
i=Image.open(r"C:\Users\Evelyn\Desktop\C33P1thinF_IMG_20150619_114756a_cell_179.png")
iar=np.asarray(i)
    print(iar)

Im trying to get python to print the array of the image in the path. if I print out the image it prints correctly but when i print the array all that prints out is

[[[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]]

     [[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]]

     [[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]]]

Is there any way I can fix this?

Giorgos Myrianthous
  • 36,235
  • 20
  • 134
  • 156
Eve M
  • 27
  • 2
  • Have you checked if the dimensions match? May it happen that the image has black bacground? – tevemadar Oct 06 '19 at 21:15
  • 2
    Please check `iar.min(), iar.max()` to verify it's all zeros (probably it's not, just the parts that are printed are). – a_guest Oct 06 '19 at 21:29
  • @a_guest does the black background affect it? – Eve M Oct 06 '19 at 23:58
  • @tevemadar how do I check the dimensions? – Eve M Oct 06 '19 at 23:59
  • @EveM As indicated by the `...` you're not viewing the full array, only parts of it (actually the first and last 3 pixels of the first and last 3 rows). So effectively you get a glimpse on the four 3x3 corners of the image. If they happen to be all black for whatever reason, this will be represented by zeros in the image data. – a_guest Oct 07 '19 at 00:09
  • @a_guest is there any way I can see the full array then? – Eve M Oct 07 '19 at 00:32
  • `iar.shape()`. The black thing was me too: black is represented as a pixel with red, green and blue components are all 0. So `[0,0,0]`-s are black pixels and if there are lots of black at the top and on the bottom of the image, you will see lots of these 0-s at the beginning and at the end of the printout. – tevemadar Oct 07 '19 at 08:29
  • @EveM See [this question](https://stackoverflow.com/q/1987694/3767239). – a_guest Oct 07 '19 at 10:33

0 Answers0