lightness algorithm using HSI - image-processing

Anyone know any algorithm to non-linearly change lightness using HSI model?
I am currently doing something like this.
new intensity = old intensity^(1/4)
It increases lightness of dark color more than lightness of bright color.
The problem is that before enhancement, if I have some pixels look like black color because of very low lightness, their lightness increase after enhancement and their actual colors appear which make black area of photo has different colors(eg: grey,blue). I have tried quite a few ways to solve it by lowering new lightness of black spot but I have no luck so far.
Is there anyway to solve it or is there better algorithm? The problem is only with color which appear to be black before enhancement.
Please help. Thank a lot.

The HSI values of dark pixels are usually degenerate. This is because, for example, a fully saturated maximally-dark blue = black, is identical in appearance to a completely de-saturated (grey) pixel at its darkest = black (this is the reason the 3D space shape usually has a pointed tip at the degenerate/singular colors).
You should not enhance pixels under a certain threshold value, or alternatively, use some weighting function that inhibits enhancement at the very dark values.

Related

How does Photoshop Camera RAW/Lightroom's Color Calibration Tool Work?

I want to try and reverse engineer the camera calibration panel in the camera raw filter in Photoshop/Lightroom.
Photoshop Colour Calibration Tool
It can create some pretty cool effects, so I want to write a program what will help automate these effects. I've attempted to try and figure out how it works, it seems to work differently from the HSL colour adjustment methods in that just moving the "Blue Primary" slider seems to affect all colours not just the blue hues (it even affects some colours that begin as solid red).
I've tried to graph out the sort of function this would do, since it seems to do something along the lines of shifting the hue of the actual blue colour in RGB to be whatever you shift the hue by, but I'm not sure what this actually means.
Here's an unmodified graph of hues relating to RGB values.
Here's the same graph, but by shifting the blue primary hues all the way to the left.
I know it's doing more than just hue shifting, since just running the filter on a hue spectrum with L/S both at 100% seems to actually change the lightness and saturation on some of the hues, see images linked below for an example.
Regular Hue Spectrum
Hue Spectrum with Blue Primary slider all the way to the left.
Is there any other open source software that does something like this that I can look to for code, or possibly an idea of how this actually works under the hood?
I figured it out (at least what I believe they're doing). So if anyone else has the same question, what they're doing is by taking advantage of the chromaticity coordinates for each of the RGB colours in the RGB -> XYZ colour space conversion. So when shifting the hue of the blue coordinate, I think they're first just shifting the hue of the blue in HSL, then taking that colour of the shifted hue, converting it into XYZ, then projecting the XYZ onto XY to get the chromaticity coordinate for the shifted blue. Then to apply that to an image, just converting from RGB to XYZ with the shifted coordinate, and converting back into RGB with the unshifted XYZ conversion matrix.

Is Intensity Slicing the Same with Color Maps Implementation in OpenCV?

I was really confuse between intensity slicing and color map implementation in OpenCV. Is the color maps implementation in OpenCV the same with the concept of intensity slicing? Can anyone clarify this to me. Your help will be very much appreciated. Thank you.
Intensity slicing is more like a thresholding action. You have 2 kinds, one is without background, so black, and the selected greyscale colors are white. In OpenCV this can be achieved with threshold or inRange. The second one is with background, which you turn certain greyscale values white and the rest you leave them as they are... I do not know any OpenCV function that do this... but it can be easily achieve with inRange to get the binary mask and then setTo with the mask and to color white.
Now, the color mapping is actually as its name says, mapping colors :) This means that for each "colormap" it has a color value for each 8 bit greyscale value, i.e. 256 colors. Then it creates a new colored image by putting a color value that mapped the value of the greyscale pixel intensity. In the "Jet" colormap, 0 in greyscale will be mapped to a dark blue. And 255 in greyscale will mapped to a dark red.

Perlin noise, how to detect bright/dark areas?

I need some help with perlin noise.
I want to create a random terrain generator. I am using perlin noise in order to determine where the mountains and sea should go. From the random noise, I get something like this:
http://prntscr.com/df0rqp
Now, how can I actually detect where the brighter and darker areas are?
I tried using display.colorSample which returns the RGB color and alpha of the pixel, but this doesn't really help me much.
If it was only white and red, I could easily detect where the bright area is (white would be really big, where red would be small number) and the opposite.
However, since I have red, GREEN AND BLUE, this makes it a hard job.
To sum up, how can I detect where the white and where the red areas at?
You have a fundamental misunderstanding here. The perlin noise function really only goes from (x,y)->p . [It also works in higher dimensions]. But what you are seeing is just your library being nice. The noise function goes from two reals to one. It is being helpful by mapping the one result value p to a color gradient. But that is only for visualization. p is not a color, just another number. Use that one directly! If p<0 you might do water.
I would suggest this:
1. Shift hue of the image into red color like here
2. Use red channel to retrieve some mask.
3. Optional: scale max/min brightness into 0-255 range.

how to understand the singularity of saturation by RGB(0,0,0)

i have not found an article to explain why by transofrmation RGB Color model to HSI we have undefinde Saturation when the color is black?
Qeustion1: what is the explation of this (the mathematic reason)
Question2: when the singularity is in the black color, that means we could not define what is the Saturation. but the Question then why the HSI is sensitiv to error also when the Saturation is small(not Zero but in the near from Zero). i have read that it is better not allow the saturation to be very small?
The mathematical reason is an indeterminate form 0/0. It should be intuitive that "there is nothing to see" in black.
The saturation of RGB 0,0,0 cannot be calculated and is therefor defined as zero.
S = (max(r,g,b) - min(r,g,b)) / max(r,g,b)
You see that r=g=b=0 would result in a problem as we cannot devide by 0.
The formula also shows that very small saturation values can only occur if we have very similar RGB values. If a pixel has a low saturation it is "more gray" or more achromatic. It doesn't make much sense to apply colour based rules to non-colours.

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