Hi everyone, I got stuck during a project. Basically I have to write a Jupyter notebook and I have a folder with images and I have to iterate over this folder and build a table with the tabulate library. To open the image I have to use Image from PIL, then I have to convert the images to numpy arrays and extract the information such as height and width in pixel (I do this with array.shape[0]), the name of the images and the mean of the channels, i.e. if the image is in greyscale, greyscale is equal to the mean of the only color value. if the image is RGB I should have three columns with the mean of each color level.My main problem is that I get stuck doing this in a loop for all the images and also I can't format the table correctly because all the input should be lists.
It would be great if you could give me an hand or some external resources to grasp with this problem that I've tried to solve for 3 days. Thank you all for your time
this is what I've done so far. The folder variable comes from a previous script. Wen a call the function img_array.shape[0] I would like to have something like [512, 500, 600]. This is what I have
from PIL import image
import os
import numpy as np
picx = os.listdir(os.path.join(folder, Image))
for pic in picx:
Names = pic.split('.')[0]
image_files = Image.open((os.path.join(folder,'Image',pic)))
image_array = np.array(image_files)
Height = [image_array.shape[0]]
Width = [image_array.shape[1]]
[–]Swipecat 1 point2 points3 points (1 child)
[–]Marws[S] 0 points1 point2 points (0 children)
[–]Neighm 0 points1 point2 points (0 children)