Is albumentation's colorjitter just brightness, contrast, saturation and hue operations run sequentially? - opencv

colorjitter in the albumentations frameworks have different color configuration parameters: brightness, contrast, saturation and hue. Are these equivalent to RandomBrightness, RandomContrast...? Just that they are applied on the same call?

Related

generate colors with the same perceived brightness and saturation

I want to generate a rainbow of colors, with the same perceived brightness, and same perceived saturation.
In essence, I am looking for a formula that takes three parameters: getRgbColor(hue, perceived_brightness, perceived_saturation) and returns the corresponding color, or some sort of error if no color with these constraints exists.
By "same perceived brightness" I mean: an average person seeing these colors on their average monitor would say that these colors appear to be about as bright as one particular shade of gray.
By "same perceived saturation" I mean: an average person seeing these colors on their average monitor would say that these colors appear to be equally colorful, when compared to that shade of gray.
Everyone will perceive colors a bit differently, so I am seeking an average consensus.
According to my understanding, to generate colors of the same "perceived brightness", I could use the CIELAB color space, and set the [L]uminosity. But then I do not know what values to use for a and b, and how to set the saturation, or the hue.
To generate colors of the same "perceived saturation", I think I could use the HSV or HSL color space, and set the [S]aturation. But in those color spaces, the "perceived brightness" does not seem to correspond to the [V]alue or [L]ightness. A shade of blue appears much darker than a shade of yellow with the same value, or the same lightness.
I am using opencv for the graphics output, and I am looking for either a way to calculate these colors in opencv, or a general formula.
With colour values represented in CIE L*a*b*, it is possible to perform a conversion to cylindrical coordinates, i.e. CIE L*C*Hab*, to separate hue and saturation components: https://en.wikipedia.org/wiki/CIELAB_color_space#Cylindrical_representation:_CIELCh_or_CIEHLC

why $ff008000 is pure green and not $ff00FF00?

I don't understand why $ff008000 is pure green and not $ff00FF00 (with is lime) ? I was thinking that TAlphaColor is formed of four channels (ARGB) specified as 4-byte hexadecimal number. so how $ff008000 with have 80 in the g channel could be pure green and $ff00FF00 with have ff in the g channel can be lime ?
Green = TColor($008000);
Lime = TColor($00FF00);
The naming of the colors is what is giving you a difficulty.
Instead of the RGB color model, think of the HSB (Hue, Saturation, Brighness - also known as HSL - Hue Saturation - luminance) color model.
In that model the amount of color is given by the Saturation, and the 'color' is given by the Hue, so any color with the same value for Hue and Saturation can be said to be the same color even though they won't look the same if the brightness is different. We could say that a fully saturated color is 'pure' but we still have colors that look different because of the different brightness levels.
Pure is just a label here, they could have called it 'only' to have the same meaning.

k-means clustering on RGB or HSV scale?

I want to segment an image but someone told me that the Euclidean distance for RGB is not as good as HSV -- but for HSV, as not all H, S, V are of the same range so I need to normalize it. Is it a good idea to normalize HSV and then do clustering? If so, how should I normalize on HSV scale?
Thanks
As HSV components are signify Hue, Saturation and gray intensity of a pixel they are not correlated to each other in terms of color, each component have its own role in defining the property of that pixel, like Hue will give you information regarding color (wavelength in other terms) Saturation always shows how much percentage of white is mixed with that color and Value is nothing but magnitude of that color(in other term Intensity), that is why all components of HSV space not follow same scale for representation of the values while hue can goes negative(because these are cyclic values) on the scale as well but intensity (V) will never goes negative, so normalization will not help in clustering much, the Better idea is you should apply clustering only on Hue if you want to do color clustering.
Now why Euclidean is not good for multi-channel clustering is because its distribution along mean is spherical(for 2D circular) so if it can not make any difference between (147,175,208) and (208,175,147) both will have same distance from the center, its better to use Mahalanobis Distance for distance calculation because it uses Co-variance matrix of the components which makes this distance distribution Parabolic along the mean.
so if you want to do color segmentation in RGB color space use mahalanobis distance(but it will computationally extensive so it will slows down clustering process) and if you want to do clustering in HSV color space use Hue for the segmentation of colors and than use V for fine tuning of segmentation output.
Hope it will help. Thank You
Hue is cyclic.
Do not use the mean (and thus, k-means) on such data.
Firstly you need to know why HSV is more preffered than RGB in image segmentation. HSV separates color information (Chroma) and image intensity or brightness level (Luma) which is very useful if you want to do image segmentation. For example if you try to use RGB approach for a photo with sea as the background there is a big chance the dominant RGB component in the sea is not blue (usually because of shadow or illumination). But if you are using HSV, value is separated and you can construct a histogram or thresholding rules using only saturation and hue.
There is a really good paper that compared both RGB and HSV approach and I think it will be a good read for you -> http://www.cse.msu.edu/~pramanik/research/papers/2002Papers/icip.hsv.pdf

HSI and HSV color space

What is the difference between HSI and HSV color space? I want to use HSI color space but I did not find any useful material for HSI. Is HSI the same as HSV?
HSI, HSV, and HSL are all different color spaces. Hue computation is (as far as I can find) identical between the three models, and uses a 6-piece piece-wise function to determine it, or for a simpler model that is accurate to within 1.2 degrees, atan((sqrt(3)⋅(G-B))/2(R-G-B)) can be used. For the most part, these two are interchangeable, but generally HSV and HSL use the piece-wise model, where HSI usually uses the arctan model. Different equations may be used, but these usually sacrifice precision for either simplicity or faster computation.
For lightness/value/intensity, the three spaces use slightly different representations.
Intensity is computed by simply averaging the RGB values: (1/3)⋅(R+G+B).
Lightness averages the minimum and maximum values for RGB: (1/2)⋅(max(R,G,B) + min(R,G,B)).
Value is the simplest, being the value of the maximum of RGB: max(R,G,B).
When used in subsequent calculations, L/V/I is scaled to a decimal between 0 and 1.
Saturation is where the three models differ the most. For all 3, if I/V/L is 0, then saturation is 0 (this is for black, so that its representation is unambiguous), and HSL additionally sets saturation to 0 if lightness is maximum (because for HSL maximum lightness means white).
HSL and HSV account for both the minimum and maximum of RGB, taking the difference between the two: max(R,G,B) - min(R,G,B), this value is sometimes referred to as chroma (C).
HSV then takes the chroma and divides it by the value to get the saturation: C/V.
HSL divides chroma by an expression taking lightness into account: C/(1-abs(2L-1)).
HSI doesn't use chroma, instead only taking min(R,G,B) into account: min(R,G,B)/I.
Sources
Wikipedia: HSL and HSV
Wikipedia: Hue
From the mathematical formula, the Hues are the same for HSV and HSI when you are trying to make the conversion from RGB to one of them.
Saturation in HSL is dependent on max, min, and Lightness, while HSV's Saturation is only max and min dependent. (max and min are the maximum and minimum pixel value among R, G, B space).
Value is max while the Lightness is (max + min)/2
Appendix: RGB->HSV, RGB->HSL

How can I generate multiple shades from a given base color?

I'd like design a chart and set the colors
from a single exemplar. Same way as in Excel's:
Is there some sort of a formula or algorithm to
generate the next shade of color from a given
shade or color?
That looks to me like they just took the same hue (basic color) and turned the brightness up and down. That can be done easily enough with a HSL or HSV transformations. Check Wikipedia for HSL and HSV color spaces to get some understanding of the theory involved.
Basic idea: Computers represent color with a mixture of red intensity, green intensity and blue intensity, called RGB, because that's the way the screen displays color. HSL (Hue, Saturation, Lightness) and HSV (Hue, Saturation, Value) are two alternative models for representing color that are more intuitive and closer to the way human beings tend to think about how colors look.
Hue is the basic color, represented (more or less) as an angle on a color wheel. Saturation is a linear value, from 0 (gray) to 255 (bright, vibrant color). And Lightness/Value represent brightness, from 0 (black) to 100 (white).
The algorithms to transform from RGB -> HSL and HSL -> RGB (or HSV instead of HSL) are pretty straightforward. Try transforming your color to HS*, adjusting the brightness, and transforming back. By taking several different brightness values from low to high, and arranging them as wedges in a pie chart, you can duplicate that picture pretty easily.
Look into the HSV colour space. Using it you can produce different shades or tints starting from a given colour. There is a page with Pascal / Delphi code for conversion between RGB and HSV at efg's Computer Lab.
Roderick , the #mghie links are great to start, additionally try out the Colorlib Delphi Library , wich lets you convert between color models as well as HTML color conversion utilities. is very complete, full source code included and freeware ;).
check the demo application , in this image you can see a blue pallete generated using this library.

Resources