1 | initial version |
The simplest solution is to quantize first the image into 8 levels simply by dividing it by 32 (integer division). Then, every channel will range between 0..7
.
Rq=R//32
To get the Hrgb
,combine the three channels into one:
Himg=Rq+Gq*8+Bq*64
Himg
will contain values between 0...511, corresponding to the 512 bins of Hrgb
. So you only need to build the histogram for Himg to get Hrgb
(using cv2.hist()
or numpy.histogram()
)
Hrgb = cv2.calcHist([Himg],[0],None,[512],[0,512])