Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

python: how to compute the color distribution of image in the paper with python and openCV

I am computing the color distribution of image as mentioned in the paper: https://arxiv.org/pdf/1202.2158.pdf.

3.1.2 Color Distribution


To avoid distraction from objects in the background, professional photographers tend to keep the background simple.
In [19], the authors use the color distribution of the background to measure this simplicity. We use a similar approach
to measure the simplicity of color distribution in the image. For a given image, we quantize each RGB channel into
8 values, creating a histogram Hrgb = {h0, h1, · · · , h511} of 512 bins, where hi indicates the number of pixels in
i-th bin. We define feature f4 to indicate the number of dominant colors as f4 =  512 1(hk ≥ c2 maxi hi) where k=0
c2 = 0.01 is the threshold parameter. We also calculate the size of the dominant bin relative to the image size as f5 = maxi hi .

I am no sure the meaning of we quantize each RGB channel into 8 values. How to quantize the RGB into 8 values. and Hrgb of 512 bins. Hrgb is the sum of R, G, B of histogram or not?

and I have read the image with opencv to get there channel data as following code.

image = cv2.imread(img)
B = image[:, :, 0]
G = image[:, :, 1]
R = image[:, :, 2]