How do you check if any RGB or hex value is within the colors of a specific category? Probably with Ruby.
I am using ruby and rmagick to remove the color (volume and color_histogram) from the images and then store those colors in the database. If someone is searching for color (hex or RGB), then I want to be able to return that color.
If someone is searching for #f4f4f4, then I would like to # f5f5f5, # f3f3f3 and all other hex values return.
If you consider RGB as a three-dimensional space with R, G and B axes , Then you can define "close color" in the form of a circle around the cube or color and return all the colors inside it (or check a given color if it is quite close). Forms are quite simple for this:
Basic color R, G, B cube around it, all the colors (R - L / 2, G - L / 2, B - L / 2) and (R + L / 2, G + L / 2, B + L / 2) Area with Radius R around it: New color is in R_new, G_new, B_new if delta_r * delta_r + delta_g * Delta_g + delta_b * delta_b & lt; R * R where delta_r = ab (del r_nu) delta_g = abs (g - g_nu) delta_b = abs (b - b_nee) using a circle rather than a cube " Is right "way, but it will not make a difference for small people and it will be easy to calculate the colors inside the cube.
Comments
Post a Comment