After my program assembles an image from three layers (see: Constructing an Image), it increases the contrast to the final image (“post-processing”) before saving it to disk.
This is done mainly to reduce the impact of the similarity shading layer (and to a lesser extent, the line glow layer) so that the lines stand out more.
How It Works
Contrast adjustment works by adjusting the RGB values of each pixel on an image away from (plus contrast) or towards (minus contrast) the center (127.5). This is done separately for the R, G, and B components.
The further away from the center, the larger the adjustment until the cap or floor is reached.
Here’s an example for a few shades of green (RGB: 0,255,0)
Contrast | G | New G |
+17 | 150 | 158 |
+17 | 200 | 227 |
+10 | 200 | 215 |
-10 | 200 | 186 |
+17 | 221 | 255 |
Note that with a contrast adjustment of +17, there is no difference between a starting color of (0,221,0) and (0,255,0). I use +17 as an example because it is the current default setting in my program.
The Impact on Hue
Because the adjustment is done separately on the R, G and B components, the contrast adjustment can effectively change the hue of a color. The hue is not changed for shades primary colors (e.g, 128,0,0) or secondary colors (e.g, 128,128,0), but it can change for tertiary colors (e.g., 128,64,0), which becomes more red (128,41,0).
Colors with tints (RGB values all above 0) are even more complicated.
A Sample Image
I’ll use this image to show the effects of the contrast adjustment, which I also used to demonstrate the different similarity shading options:
The Impact With And Without Similarity Shading
The bottom images are the top images with a +17 contrast adjustment. The right images have similarity shading and the left images don’t.
Here’s one particular area that I think is interesting:
originally, I was going to do some RGB color picking on specific cells, but nah. The similarity shading blends with both the line glow layer and the lines such that the contrast adjustment isn’t so easy to predict.
Adjusting the Contrast Separately for the Layers
To get from the top left to the bottom right images, the program overlays the similarity on top of the image and then increases the contrast.
Now I will show what happens if the contrast is adjusted separately for the two layers.
First, here is the similarity shading layer on a black background before and after the contrast boost:
I’ve already shown the line glow layer with the contrast increased (the top right quadrant). Here is what that image looks like with the right side of the last image on top of it:
And a slightly larger area of interest to compare:
the bottom version is with the contrast adjustment done after adding the similarity shading layer.
It is interesting (to me at least) because the similarity shading simultaneously has both more and less impact. There’s a depth to the image that isn’t quite achieved either with no contrast adjustment or the contrast adjustment done separately, which is the main reason I chose it for the Image(s) of the Day.
Adjusting the Color Palettes
The color palettes I use were created with the contrast adjustment in mind.
The image above uses the Dark 24 color palette:
The left side are the actual colors in the theme, and the right side are those colors adjusted for contrast.
The program starts with the colors on the right side, and then finds the color on the left side that makes it look like the right side with the contrast adjustment.
The 255s and 0s
In the above palette, there is one color that is unchanged from the left to the right. Can you spot it?
It’s the 2nd color in the top row, which is just plain blue. Why is it unchanged? The program could have started with 0,0,221 instead of 0,0,255 and anything in between and the right side would be unchanged. I chose to make it pick 255 for max values and 0 for min values (where anything 34 or less reduces to 0).
While it doesn’t make a difference to the colors on their own, when blended with the line glow and similarity shading layer, there is a difference, and sometimes significant.
Next page (need to add link, tints and stuff).