Skip to content

laserwave/ColorHistogram

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Color Histogram Demo (Python)

Simple python demos of Color Histogram.

This package includes:

Examples

Histogram 1D:

Histogram 1D plotting in 1 channel from RGB, Lab, HSV color spaces.

Minimal example:

from color_histogram.io_util.image import loadRGB
from color_histogram.core.hist_1d import Hist1D
import matplotlib.pyplot as plt

# Load image.
image = loadRGB(image_file)

# 16 bins, Lab color space, target channel L ('Lab'[0])
hist1D = Hist1D(image, num_bins=16, color_space='Lab', channel=0)

fig = plt.figure()
ax = fig.add_subplot(111)
hist1D.plot(ax)
plt.show()

In the following demo, I show the L (Lab), h (HSV), v (HSV) plots by changing color_space and channel.

Histogram 1D

Histogram 2D:

Histogram 2D plotting in 2 channels from RGB, Lab, HSV color spaces.

Minimal example:

from color_histogram.io_util.image import loadRGB
from color_histogram.core.hist_2d import Hist2D
import matplotlib.pyplot as plt

# Load image.
image = loadRGB(image_file)

# 32 bins, hsv color space, target channels (h, s) ('hsv'[0], 'hsv'[1])
hist2D = Hist2D(image, num_bins=32, color_space='hsv', channels=[0, 1])

fig = plt.figure()
ax = fig.add_subplot(111)
hist2D.plot(ax)
plt.show()

In the following demo, I show the (h, s), (h, v), (s, v) plots by changing channels.

Histogram 2D

Histogram 3D:

Histogram 3D plotting in RGB, Lab, HSV color spaces.

Minimal example:

from color_histogram.io_util.image import loadRGB
from color_histogram.core.hist_3d import Hist3D
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Load image.
image = loadRGB(image_file)

# 16 bins, rgb color space
hist3D = Hist3D(image, num_bins=16, color_space='rgb')

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
hist3D.plot(ax)
plt.show()

In the following demo, I show the RGB, Lab, HSV plots by changing color_space.

Histogram 3D

Installation

Note: This program was only tested on Windows with Python2.7. Linux and Mac OS are not officially supported, but the following instructions might be helpful for installing on those environments.

Dependencies

Please install the following required python modules.

  • NumPy
  • SciPy
  • matplotlib
  • OpenCV

As these modules are heavily dependent on NumPy modules, please install appropriate packages for your development environment (Python versions, 32-bit or 64-bit). For 64-bit Windows, you can download the binaries from Unofficial Windows Binaries for Python Extension Packages.

Install main modules

You can use pip command for installing main modules. Please run the following command from the shell.

  > pip install git+https://github.com/tody411/ColorHistogram.git

Usage

Run Color Histogram Demo

You can test the color histogram demo with the following command from color_histogram directory.

  > python main.py

This command will start downloading test images via Google Image API then run the demo module to generate result images in color_histogram/results directory.

Examples Codes

License

The MIT License 2015 (c) tody

About

Color Histogram (support python3).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%