I've an application that indexes the top 16 colors that appear in videos.
I'm trying to write another application that allows the user to select a color and then the application finds all videos that this color appears in.
The problem is that as I only index 16 colors per video, the users choose an RGB color. The probability that this color is indexed is very low, so almost always my application returns no results.
I thought of a way I could make this work - I could index the colors that appear in the video and convert them to closest 8-bit color.
Then when a user selects an RGB color, I could convert the user choice to the same 8-bit closest color.
This way I'd always have matches.
The only major problem I've right now is how to convert an RGB color to the closest 8 bit color?
In the example 8-bit color, red and green are each 3 bits (8 possible values) and blue is 2 bits (4 possible values). After you get these three components, you can combine them with some simple bit shift arithmetic: Then you can simply compare these 8-bit colors. Their drastically reduced resolution may help you.
If you'd rather change the color of an individual RGB component, click Device in the left panel and select the device. If it's currently synced with other accessories, click Un-sync when prompted. Now you can choose any of the basic effects, or click AURA Creator to create advanced effects.
RGB to Pantone converter is a free browser-based online color converter that quickly converts the RGB color value to Pantone color value with the best possible outcomes. RGB stands for Red, Green, and Blue.
In your original 24-bit color, red, green, and blue can all have 256 possible values, so that is the divisor of the scaling equation. In the example 8-bit color, red and green are each 3 bits (8 possible values) and blue is 2 bits (4 possible values).
To convert to the web-safe palette, you need to convert the range of each of the r,g,b components from 0-255 to 0-5 and combine them:
color = (r*6/256)*36 + (g*6/256)*6 + (b*6/256)
What you need to do is convert the RGB to an HSB (hue saturation brightness) value. HSB is 3 bytes, just like RGB, the difference is that HSB values can be compared much more easily than RGB.
Your next step is decide on an "importance" weighting. For example, if all you care about is "color/hue", not saturation or brightness, then you can throw away the S and B bytes and just use the color byte.
If it were me and I were constrained to 8 bits I would use 4 bits of color information (16 different colors), 3 bits of saturation (8 different values), and 1 bit of brightness information (light or dark).
This article describes how to do HSB in Java:
http://java.sys-con.com/node/43559
The source code for this article has an RGB to HSB converter in Java.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With