Question: I need help with python programming Storing the images into data matrix, Shows histogram from a gray scale Image, and Shows histogram from a color

I need help with python programming

Storing the images into data matrix, Shows histogram from a gray scale Image, and Shows histogram from a color image in the following code.

from PIL import Image import numpy as np import os #import pandas as pd

img_db = [] img_lb = []

# Fruit_folder has six elements fruit_folder = os.listdir("FruitDB/")

for k, file in enumerate (fruit_folder): path = "FruitDB/"+ file +"/"; image_name = os.listdir(path) for img_name in image_name: img = Image.open(path+img_name).convert('L') # read and convert to gray scale img = img.resize((50,50)) img2 = np.asarray(img) img2 = img2/255 img_db.append(np.ravel(img2))

img_lb.append(k); data_mat = np.stack(img_db, axis = 0)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!