hp
toc

Rainbowify

2017-09-23, post № 180

PIL, programming, Python, #color model, #hsl, #hsv, #image filter, #images, #nature, #photography, #rainbow

To digitally represent colors, one most often uses the RGB color system. By combining three fundamental light colors in certain ways, one can define a variety of different wavelengths of light. The human eye has three distinct photoreceptors for the aforementioned three colors, nearly all screens use pixels consisting of three parts in those colors and most image formats store the image data in the RGB color system.

rainbowify-137_rainbowified.jpg
Honey bee (original)

However, there are other color systems than RGB with other strengths. Cycling through the colors of the rainbow, for example, is a lot easier using the HSL (or HSV) color model, as it is simply controlled by the hue.

rainbowify-154_rainbowified.jpg
Fruit (original)

Rainbowify uses the HSL color model to rainbowify a given image. To do so, the image is first converted into a grayscale image (averaging all three color channels). A pixel’s brightness is then interpreted as its hue with its saturation and lightness set to the maximum. As a final touch, the hue gets offset by a pixel-position dependent amount to create the overall appearance of a rainbow.
Source code is listed below and can also be downloaded.

rainbowify-124_rainbowified.jpg
Sunflower (original)
rainbowify-123_rainbowified.jpg
Thistle (original)
Source code: rainbowify.py
Extra assets: rainbowify-120.jpg, rainbowify-120_rainbowified.jpg, rainbowify-121.jpg, rainbowify-121_rainbowified.jpg, rainbowify-122.jpg, rainbowify-122_rainbowified.jpg, rainbowify-125.jpg, rainbowify-125_rainbowified.jpg, rainbowify-126.jpg, rainbowify-126_rainbowified.jpg, rainbowify-127.jpg, rainbowify-127_rainbowified.jpg, rainbowify-128.jpg, rainbowify-128_rainbowified.jpg, rainbowify-129.jpg, rainbowify-129_rainbowified.jpg, rainbowify-130.jpg, rainbowify-130_rainbowified.jpg, rainbowify-131.jpg, rainbowify-131_rainbowified.jpg, rainbowify-132.jpg, rainbowify-132_rainbowified.jpg, rainbowify-133.jpg, rainbowify-133_rainbowified.jpg, rainbowify-134.jpg, rainbowify-134_rainbowified.jpg, rainbowify-135.jpg, rainbowify-135_rainbowified.jpg, rainbowify-136.jpg, rainbowify-136_rainbowified.jpg, rainbowify-138.jpg, rainbowify-138_rainbowified.jpg, rainbowify-139.jpg, rainbowify-139_rainbowified.jpg, rainbowify-140.jpg, rainbowify-140_rainbowified.jpg, rainbowify-141.jpg, rainbowify-141_rainbowified.jpg, rainbowify-142.jpg, rainbowify-142_rainbowified.jpg, rainbowify-143.jpg, rainbowify-143_rainbowified.jpg, rainbowify-144.jpg, rainbowify-144_rainbowified.jpg, rainbowify-145.jpg, rainbowify-145_rainbowified.jpg, rainbowify-146.jpg, rainbowify-146_rainbowified.jpg, rainbowify-147.jpg, rainbowify-147_rainbowified.jpg, rainbowify-148.jpg, rainbowify-148_rainbowified.jpg, rainbowify-149.jpg, rainbowify-149_rainbowified.jpg, rainbowify-150.jpg, rainbowify-150_rainbowified.jpg, rainbowify-151.jpg, rainbowify-151_rainbowified.jpg, rainbowify-152.jpg, rainbowify-152_rainbowified.jpg, rainbowify-153.jpg, rainbowify-153_rainbowified.jpg, rainbowify-155.jpg, rainbowify-155_rainbowified.jpg, rainbowify-156.jpg, rainbowify-156_rainbowified.jpg, rainbowify-157.jpg, rainbowify-157_rainbowified.jpg, rainbowify-158.jpg, rainbowify-158_rainbowified.jpg, rainbowify-159.jpg, rainbowify-159_rainbowified.jpg
Jonathan Frech's blog; built 2024/08/31 22:59:44 CEST