'Why is there an extra row of zeros in the histogram of images in a folder?
I have a folder comprising 20 images (.jpg format). I am trying to obtain the histogram of each of the images and store it as a Pandas data frame. My code is shown below:
import os
import cv2
import numpy as np
import pandas as pd
hist = []
for filename in os.listdir("/path/to/images"):
img = cv2.imread(os.path.join("/path/to/images", filename))
hist.append(cv2.calcHist([img], [0], None, [256], [0, 256])[:, 0])
histogram = pd.DataFrame(hist)
I expect the data frame "histogram" to be of shape (256,20). However, I get a (256,21) shaped data frame with one row full of zeros. I have no idea why this row of zeros appears. Is there an error in my code?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
