Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I turn an image(probably RGB jpeg) into 3 bit color with irregular color palette?

Long story short, there is this hardware that can only display around 6-7 types of irregular pixels like (47,160,30), (229,52,10),(0,60,190), etc. How do display an RGB image with these irregular pixels with minimum error? My approach is just displaying the pixel closest to the original(by checking the difference on RGB values) with dithering, but the results seem always off. Is there a way I can somehow compare the colors, or any book I can refer to?

like image 466
Yunsheng Guo Avatar asked Dec 07 '25 08:12

Yunsheng Guo


1 Answers

In order to calculate the distance between colours from a human point of view you will need to convert RGB to a Lab colour space. This wikipedia article has all math you will need: https://en.wikipedia.org/wiki/Color_difference and this one https://en.wikipedia.org/wiki/Lab_color_space#RGB_and_CMYK_conversions has the math on conversion between RGB and Lab

A solution is also proposed in this answer: Compare RGB colors in c#

And a library available here: https://github.com/THEjoezack/ColorMine

like image 104
bib1257 Avatar answered Dec 08 '25 22:12

bib1257



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!