Python Forum
Attribute Error - trying to create a pixel array out of PNG files
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Attribute Error - trying to create a pixel array out of PNG files
#1
Have 40 PNG files, ground truth labels for 40 DICOM images, that I am attempting to convert into an array for input into a Fully Convolutional Neural Network.

Linked the files to a Google Colab notebook from my Google Drive and globbed them together via the masks variable that has a length of 40 via the print(len(masks)) call. However, when I attempt to read each individual PNG file and append its pixel data to the pixel_data1 array, I receive the "AttributeError" below.

The PNG files are of different sizes (256 x 256, 288 x 288, and 320 x 320), as was the case with the 40 DICOM files that I have created the pixel array from in a similar code block as below.

Tried to also use cv2.imread() for dataset1 but also have had no success in running the for loop successfully.

pixel_data1 = []
masks = glob.glob("/content/drive/My Drive/Masks/IMG*.png");
for mask in masks:
    dataset1 = imageio.imread(mask)
    pixel_data1.append(dataset1.pixel_array)
print(len(masks))
print(pixel_data1)
Outputs the following error: "AttributeError: 'Array' object has no attribute 'pixel_array'"
Reply
#2
imageio documentation says imread returns a numpy array. I don't see where numpy arrays have a pixel_data attribute.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Voxel to pixel graphics voicemail 3 532 Nov-19-2023, 09:45 AM
Last Post: paul18fr
  Error: audioio has no attribute 'AudioOut' netwrok 3 592 Oct-22-2023, 05:53 PM
Last Post: netwrok
  cx_oracle Error - AttributeError: 'function' object has no attribute 'cursor' birajdarmm 1 2,206 Apr-15-2023, 05:17 PM
Last Post: deanhystad
  Pixel color and action Sartre 4 1,965 Apr-13-2023, 03:26 AM
Last Post: Sartre
  Create new folders and copy files cocobolli 3 1,330 Mar-22-2023, 10:23 AM
Last Post: Gribouillis
  Dynamic pixel display jerryf 2 675 Mar-17-2023, 07:26 PM
Last Post: jerryf
  numpy.array has no attribute head Led_Zeppelin 1 1,190 Jul-13-2022, 12:56 AM
Last Post: Led_Zeppelin
  Create array of values from 2 variables paulo79 1 1,055 Apr-19-2022, 08:28 PM
Last Post: deanhystad
  Python code to read second line from CSV files and create a master CSV file sh1704 1 2,352 Feb-13-2022, 07:13 PM
Last Post: menator01
  Getting 'NoneType' object has no attribute 'find' error when WebScraping with BS Franky77 2 5,162 Aug-17-2021, 05:24 PM
Last Post: Franky77

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020