Open K0nkere opened 1 year ago
def histogram(df, name): red = []; green = []; blue = [] for i in tqdm(df.index): img_path = './images/' + df['image_id'][i] + '.jpg' img = tf.keras.preprocessing.image.load_img(img_path) x = np.array(img) red.append(np.mean(x[0][:,0])); green.append(np.mean(x[0][:,1])); blue.append(np.mean(x[0][:,2])) df['redm']= red; df['greenm']= green; df['bluem']= blue plt.figure(figsize = (10,5)) sns.histplot(df.redm.values, bins=80, color='red', alpha=0.3, kde=True) sns.histplot(df.greenm.values, bins=80, color='green', alpha=0.3, kde=True) sns.histplot(df.bluem.values, bins=80, color='blue', alpha=0.3, kde=True) plt.ylabel('Frequency') plt.xlabel('Intensity') plt.title('Distribution of colors in %s dataset' % name)