python: how to compute the gray level histogram features as mentioned in the paper, and
(1) how to we compute the gray level histogram Hr , Hg , and Hb for each of the red, green, and blue channels.


The gray level histogram for each of the channels is simply the gray level histogram of the Red channel, the Green channel and the Blue channel separately. Instead of converting the image from RGB to grayscale, try to extract its RGB components.

For example, in GNU Octave, a colour image is represented as a $M \times N \times D$ matrix, where $M$ is the height of the image, $N$ is the width of the image and $D$ is the "number of channels".

In a colour RGB image, the number of channels is 3.

This can be viewed as 3 images packed together in one "3D" matrix. To work on the Red channel, all that you have to do is use slicing to obtain just one of those matrices.

In Octave, this would be done via:

image = imread("someimage.png")
red_channel = image(:,:,1)


Similar thinking applies to other languages / computing platforms.


  2) how to compute the the contrast quality, qct mentioned in the paper.


According to the paper, the $q_{ct}$ is the width of the 98% "part" of the combined histogram.

So:


Load the image
Get the histogram of the Red Channel (call it $H_r$)
Get the histogram of the Green Channel (call it $H_g$)
Get the histogram of the Blue Channel (call it $H_b$)
Produce the combined histogram as $H = H_r + H_b + H_g$
Get the 98% of its mass:


Sort $H$ in reverse order of values (largest count comes first)
Get the cumulative sum of the histogram values until you have covered the 98% of the total sum.
Find the minimum and maximum values of the indices of the values that contribute to the sum
Calculate the $q_{ct}$ as the difference between the maximum and minimum of the indices.



Hope this helps.