Attribute Error - trying to create a pixel array out of PNG files - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Attribute Error - trying to create a pixel array out of PNG files (/thread-26377.html) |
Attribute Error - trying to create a pixel array out of PNG files - The_Sarco - Apr-29-2020 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'" RE: Attribute Error - trying to create a pixel array out of PNG files - deanhystad - Apr-29-2020 imageio documentation says imread returns a numpy array. I don't see where numpy arrays have a pixel_data attribute. |