Python Forum
Issue with creating an array of pixel data for PNG files in Google Colab
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issue with creating an array of pixel data for PNG files in Google Colab
#1
Trying to create an array of pixel data corresponding to a dataset of 40 PNG files contained within my Google Drive, using Google Colab.

Managed to accomplish the listed goal for 40 DICOM fils, using pydicom.dcmread() in place of imageio.imread() below in the code block. However, I keep receiving empty values for the print statements below. Tried using cv2.imread() as an alternative and the program provides an error message of "File Not Found" for the directory listed in the glob.glob() call.

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)
The above code outputs 0 and [], respectively, for the print statements. Is there a program that can read the elements in the masks statement and then append the pixel intensity values as a data array to create the pixel_data1 vector?
Reply
#2
If len(masks) is zero, then your glob is not matching any files. Perhaps your directory is off. The loop is never run.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is it possible to extract 1 or 2 bits of data from MS project files? cubangt 8 1,043 Feb-16-2024, 12:02 AM
Last Post: deanhystad
  Voxel to pixel graphics voicemail 3 567 Nov-19-2023, 09:45 AM
Last Post: paul18fr
  script to calculate data in csv-files ledgreve 0 1,093 May-19-2023, 07:24 AM
Last Post: ledgreve
  Pixel color and action Sartre 4 2,067 Apr-13-2023, 03:26 AM
Last Post: Sartre
  Dynamic pixel display jerryf 2 719 Mar-17-2023, 07:26 PM
Last Post: jerryf
  (Python) Pulling data from UA Google Analytics with more than 100k rows into csv. Stockers 0 1,217 Dec-19-2022, 11:11 PM
Last Post: Stockers
  Issue in writing sql data into csv for decimal value to scientific notation mg24 8 3,010 Dec-06-2022, 11:09 AM
Last Post: mg24
  Creating csv files from Excel file azizrasul 40 5,582 Nov-03-2022, 08:33 PM
Last Post: azizrasul
  SQL Alchemy help to extract sql data into csv files mg24 1 1,766 Sep-30-2022, 04:43 PM
Last Post: Larz60+
  Issue in changing data format (2 bytes) into a 16 bit data. GiggsB 11 2,654 Jul-25-2022, 03:19 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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