This repository contains two Python functions:
RGB2HSI
: convert RGB colour values to HSIdeltaHSI
: find the distance between two colours in HSI colour space
These functions are based on Koschan and Abidi (2008: 58-60, 63-64).
The HSI colour model represents colour as hue (H), saturation (S), and intensity (I).
(Cao, Zhu, Zhao, Liu, & Gao (2019) CC-BY 4.0) The hue describes the dominant colour represented as an angle in the range [0, 360], where red is 0°, yellow is 60°, green is 120° cyan is 180°, blue is 240°, and magenta is 300°. The saturation is the realtive purity of the colour and depends on the amount of white light present, and has the range [0, 100]. The intensity ranges from black (0) to White (100).RGB2HSI
converts RGB colour values to HSI using the following equations:
RGB2HSI
expects as input a tuple of RGB colour values. For example, to convert the RGB colour to HSI:
RGB2HSI((100, 150, 200))
returns the tuple (210, 33.3, 150).
For two colours and in HSI colour space, the distance between them is given by
where
deltaHSI
calculates this distance for two HSI colours entered as tuples. For example, where and we can determine the distance betwen them using
deltaHSI((210, 33.3, 150), (139, 57.1, 117))
which returns the result 81.45.
Cao, P., Zhu, Y., Zhao, W., Liu, S., & Gao, H. (2019) Chromaticity measurement based on the image method and its application in water quality detection, Water 11 (11): 2339. https://doi.org/10.3390/w11112339.
Koschan, A., and Abidi, M. (2008) Digital Color Image Processing. Hoboken, NJ: John Wiley & Sons.