Currently I am using the animate tag to cycle through some colors.
<animate attributeName="stop-color" begin="0s" dur="16s" values="#00ffff;#ff00ff;#00ffff" repeatCount="indefinite" />
How are the colors being interpolated, and can I use HSL instead of RGB?
Thanks.
interpolation of colours is defined in the SVG specification. Basically distance is the standard vector distance between the colours in the RGB colour space.
Even though you can specify the end states in HSL in most UAs these days you won't get HSL interpolation. Your HSL endpoint colours would be converted to RGB and then the interpolation would take place in the RGB colour space.
Related
I have an array of Colors that represents a picture. I want to find the most bold / most standout color from that frame (aka a bright pink if there is no pink in the frame or a bright yellow if there is no yellow in the frame, etc). Currently I don't know how to do this efficiently. Is there any known or efficient way of doing this efficiently for a 1280 by 720 pixel image (921,600 pixels) or any method you can think of?
As a starting point, I would say you are looking for the most saturated colour, so I would suggest converting to HSL colorspace, discarding the Hue and Lightness and seeing which one has the highest saturation.
So, for a quick example using ImageMagick using these two images:
This is the command yo would run in Terminal:
convert lighthouse.png -colorspace hsl -separate -delete 0,2 saturation.png
And here are the results - the most saturated colours show up as white.
I have a RGB color that represents light. I am looking for an algorithm to draw this over an arbitrary background (could be, for example, an image) in a way that simulates (or resembles) lighting.
Some examples:
RGB=#888888 represents white light at 50% intensity
Painting this over white (#ffffff) background pixels would do nothing
Painting this over black (#000000) background pixels would paint as #888888
Painting this over red (#ff0000) background pixels would result in a "lighter red"
RGB=#ff0000 represents red light at 100% intensity
Painting this over white (#ffffff) background pixels should result in a "light red" (mix of red and white)
Painting this over black (#000000) background pixels would paint as #880000
RGB=#000000 represents no light. Painting this over any background should have no effect.
I was hoping that I would be able to translate the original RGB color in (a set of) RGBA color(s) that I could paint over the background. I have been looking for an algorithm for this and playing around with HSL, HSB, alpha, etc. but cannot find a generic way to accomplish this.
Is there a generic algorithm to achieve what I want?
Update: I am aware of this question, but I don't think this is a duplicate (despite the similar names). The accepted answer to that question describes a behaviour (Red + Black = Dark red) that does not match this sceneario (lighting). I am specifically looking for an algorithm to simulate (colored) lighting.
If you view the values as decimal you have values that range 0-255. You could sum the two colours and then rescale them back to the range.
FF0000 + FFFFFF
= 255,0,0 + 255,255,255
= 510,255,255
Then scale this by 255/510 to
510 * 255/510, 255 * 255/510, 255 * 255/510
= 255, 127, 127
A light red as required.
Let's suppose we have a regular RGB image. Now we would want to approximate the color of each individual pixel of our source image with a color out of a small set of colors.
For example, all tones of red should be converted to that specific red out of my set of colors, same goes for green, blue, etc.
Is there any elegant way/algorithm to achieve this?
Does it mean to control the combination between an image and a color overlay applied to it depending on the color space used (RGB, RGBA, CMYK, Lab, Grayscale, HSL, HSLA)? Or does it mean to change the color layer used in combination with other layers to form the final image? (if so, what could be changed in what regard?).
RGB are abbreviations for three color channels (red, green and blue). They represent specific frequencies of light. Inside each color channel is a range of intensity and a level of saturation. This model of colors is commonly taught in school and is how most people understand colors and mixing them. A different way to represent colors is HSL which stands for Hue, Saturation and Level. Here the Hue is the frequency of the color, while the Saturation can be like the contrast level, and Level is the amount of black. HSL (A stands for Alpha or transparency) is actually a much more programmer centric way of working with color (although most programmers seem to learn the RGB Hex values for colors). There is a great website called Mothereffing HSL which lets you play with HSL values to better understand them. CMYK is for pigments (which mix differently than light) and is found on printers. Same basic idea as RGB just with Cyan Magenta Yellow and Black. Now because light and pigments don't mix the same way there is a lot of work devoted to converting one color system to another (so you can see on your screen what will eventually come out of your printer). These systems are not perfectly aligned however so the goal is to get acceptability close.
All of these colors when presented on a graph are called the color space.
I have some RGB images.
What's the best way to know most color used in an image is Red or Yellow or White?
The input images must have more than 50% red, yellow or white pixels and it's impossible to an image have two colors in same percentage.
Other colors in image may be black or blue.
Is there any function in MATLAB for this?
Note that i need a method with good performance for this!
Thanks in advance...
Convert your image to the HSV colorspace (rgb2hsv) and find appropriate thresholds for Red, Yellow and White on the Hue values. E.g.
[H S V] = rgb2hsv(I);
num_red_pixels = nnz(H>=red_min & H<=red_max);