Created
July 20, 2021 06:40
-
-
Save therealnaveenkamal/b95f99f1ec429c1544f1a8f2c7c9895b to your computer and use it in GitHub Desktop.
This code takes in a random sample image, plots a histplot and analyzes the pixel intensities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
num = np.random.randint(trainset.shape[0]) | |
sample = plt.imread(os.path.join(img_dir,trainset.iloc[[num]]["Image"].values[0])) | |
plt.figure(figsize=(15, 15)) | |
plt.title(dataframe[dataframe["Image Index"] == trainset.iloc[[num]]["Image"].values[0]].values[0][1]) | |
plt.imshow(sample, cmap = 'gray') | |
plt.colorbar() | |
trainset.iloc[[num]] | |
print("Maximum Pixel Value: ", sample.max()) | |
print("Minimum Pixel Value: ", sample.min()) | |
print(f"Image dimension: {sample.shape[0]} x {sample.shape[1]} ") | |
fig, ax = plt.subplots(figsize=(25, 10)) | |
plt.xlabel("Pixel Values") | |
print("Mean - Pixel Value: ", sample.mean()) | |
print("Std Deviation Pixel Value: ", sample.std()) | |
sns.histplot(sample.ravel(), ax = ax, kde = True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment