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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started