Created
April 14, 2017 03:42
-
-
Save dolaameng/03dde943e7a4abc8edec4aa8bd7d0550 to your computer and use it in GitHub Desktop.
color_hist
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
def color_hist(img, nbins=32, bins_range=(0, 256)): | |
# Compute the histogram of the color channels separately | |
channel1_hist = np.histogram(img[:,:,0], bins=nbins, range=bins_range) | |
channel2_hist = np.histogram(img[:,:,1], bins=nbins, range=bins_range) | |
channel3_hist = np.histogram(img[:,:,2], bins=nbins, range=bins_range) | |
# Concatenate the histograms into a single feature vector | |
hist_features = np.concatenate((channel1_hist[0], channel2_hist[0], channel3_hist[0])) | |
# Return the individual histograms, bin_centers and feature vector | |
return hist_features |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment