# The RGB Universe

One image bounded to three respective spaces: Colour, Chromaticity, and Hue.

The Colour-Space: RGB
Everyone is familiar with this, it is the additive model for colours that uses the primaries: red, green & blue. A 3D Model where each unique colour sits at position (x: r, y: g, z: b).

The Chromaticity-Space: RCGCBC
Some people will be familiar with this, it is RGB without luminance, the brightness is removed in a way that doesn’t effect the hue or saturation. It is referred to as rg-Chromaticity because it’s construction from RGB means only two elements are needed to represent all the chromaticity values:

 Conversion to Conversion from (kind of*) $R_C= \frac{R}{R+G+B}$ $G_C= \frac{G}{R+G+B}$ $B_C= \frac{B}{R+G+B}$ $R = \frac{R_C G}{G_C}$ $G = G$ $B = \frac{(1 - R_C - G_C) G}{G_C}$

It will always be that $R_C + G_C + B_C = 1$ so by discarding the blue component we can have unique chromaticities as (x: r’, y: g’). This means that rg-Chromaticity is a 2D-Model and when converting to it from RGB we lose the luminance. So it is impossible to convert back. *An in-between for this is the colour-space rgG where the G component preserves luminance in the image.

The Hue-Space: RHGHBH
No one uses this, I just thought it would be fun to apply the same as above and extract the saturation from RCGCBC. Like RCGCBC it is a 2D Model, this seems strange because it is only representing one attribute –hue– but it is because the elements themselves have a ternary relationship (how much red, how much green, how much blue) and so to extrapolate one you must know the other two.

 Conversion to 3-tuple Hue Normalise to 2D $M = \text{Max}(R,G,B)$ $m = \text{Min}(R,G,B)$ $\delta = 255/(M-m)$ $R_h = (R-m) \delta$ $G_h = (G-m) \delta$ $B_h = (B-m) \delta$ $R_H = \frac{R_h}{R_h + G_h + B_h}$ $G_H = \frac{G_h}{R_h + G_h + B_h}$ $B_H = \frac{B_h}{R_h + G_h + B_h}$

Measuring Hue Distance
The HSL colour-space records hue as a single element, H, making measuring distance as easy as $\Delta H = \sqrt{{H_a}^2 - {H_b}^2}$ where as in rg-Hue we have two elements so $\Delta H = \sqrt{({R''_a}^2 - {R''_b}^2) + ({G''_a}^2 - {G''_b}^2)}$ where $R'' = R_H$ and $G'' = G_H$ for readability. What’s interesting here is it works almost the same. Though it should be noted that on a line only two distances are equidistant to zero at one time where as in rg-Hue, on a 2D plane, there are many equidistant points around circles.

Below are images of a RGB testcard where each pixel’s hue has been measured against a colour palette (60° Rainbow) and coloured with the closest match. The rg-Hue measure has a notable consistency to it and shows more red on the right hand side than HSL, but also between the yellow and red there is a tiny slither of purple. I believe this is from the equal distance hues and the nature of looking through a list for the lowest value when there are multiple lowest values:

 Hue Distance (HSL) Hue Distance (RHGHBH)

# Editing Ultraviolet Photography

For people who do multispectral photography (infrared, visible, ultraviolet, etc) sometimes it can be tricky to achieve what you want in a traditional photo editor. That is why I am developing software to cater specifically for multispectral image processing. The software is called WavelengthPro. Below is a quick video, four images and explanations for the results.

The Resulting Images:
These four images are made from only this visible light image and this ultraviolet image. They were both taken with the same camera, Nikon D70 (hot mirror removed), using an IR-UV cut filter and the Baader-U filter. No extra editing was done.

 Dual Process Luminance Map

One often met problem in ultraviolet photography is getting the right white-balance on your camera – if you can’t achieve it you end up with rather purple pictures. In WavelengthPro there is a tool called Dual Processing where you create the green channel out of the red and blue channels which rids your image of the purpley hue.

The Luminance Map is actually a lightness map, made in HSL colour-space, it is the hue and saturation of the visible light image with the lightness of the UV image. As you can see the specular effect on the leaves completely contrasts the mat flowers. There is a good example of useful application for this method in the post Luminance Mapping: UV and Thermal.

 5to3 Map (RGBUrUb) 3to3 Map (GBU)

There are only 3 channels (ignoring alpha) for an image to be encoded into but in WavelengthPro that is attempted to be extended by mapping N channels to the 3 (RGB) output channels. A classic ultraviolet editing method is to make a GBU image, like the image on the right. The image on the left has five channels equally distributed across the three RGB channels. An array of different maps can be seen in an older post called Testing Infrared Software. If you want to download and try out the software (it’s still in alpha stage – don’t expect everything to work) then the link below will have the latest release version.

WavelengthPro Flickr Group

# Digital Orthochromatic Photography

I’m playing with ways of emulating early orthochromatic film, if anyone knows any technical aspects to this that might help – feel free to suggest ideas. So far I’m just winging it.

Light Response of Film
In terms of light covered it goes: Blue-sensitive, orthochromatic, isochromatic, panchromatic (all visible wavelengths) then super-panchromatic.

On the right is a photo of British explorers taken with orthocromatic film. Note the red on the flag is much darker than the blue area because the film isn’t receptive of red light. Looking at the spectral sensitivity (here) and (here) it’s clear the violet/blue area is the predominant band with it extending to green/yellow as well.

Test Ideas
I took an image from Google, something with the British flag, and made different Channel Maps for it. The greyscaled versions are the output images.

I used the QSE tool on WavelengthPro to make a 400nm image (the violet/blue peak) and a 580nm (the green/yellow peak) and made a 2to3 map of the peaks, the colour response worked well but the data-loss from interpolation was too much. Using the original [R,G,B] channes means I won’t lose any detail, so I tried using mainly those and came up with two maps that were pretty good – GBB and GBBV. Below are those maps and the RGB map for comparison.

 This is the RGB (panchromatic) version, the red cross on the flag is lighter than the blue parts and the sky is dark. This is a GBBtoRGB version, the cross appears darker. It’s not really true to the actual spectral response of the film. This is a GBBVtoRGB version, the V is the interpolated deep violet image. Getting there…

# Luminance Mapping: UV and Thermal

This is a very simple function of WavelengthPro, using the luminance of one image and the hue/saturation of another. All it does is convert from RGB-space to HSL-space then use the L value (lightness) of a different image. In the table below I use a visible light image and an ultraviolet image (I got them from here) and map them in two ways. The first is not a Luminance map, but a GBU map the next is a luminance map which keeps the colours of the visible light and shows them at the lightness of the ultraviolet image.

 Visible image: can’t see the graffiti well. Ultraviolet image: shows up the graffiti well. GBU map: quite a nice colour palette and shows the graffiti quite well. Luminance map: has a “Human hue” whilst showing up the graffiti really well.

It is great for showing the ultraviolet characteristics of light whilst keeping the ‘true-colour’ feel that we’ve evolved to love. This idea isn’t new though, nightvision sometimes incorporates visible and thermal bands fused together and computer vision sometimes needs more than visible colour data to interpret a scene. One (less scientific) use is to make thermal imaging look a bit more lovely. Below is a visible image, thermal image and the Luminance map (I got them from here):

# Full Spectrum Photography: Mapping

This post shows three examples of full spectrum mapping methods for multispectral photography. I’ve used some quick shots I took inbetween rain clouds so I apologise for the poor quality – especially the infrared image. All shots taken on a converted D70.

 Infrared (720nm filter) Visible light (Hoya cut filter) Ultraviolet (Baader-U filter)

The only map I see often is the classic 3to3 map. The characteristics are so that vegetation stands out in a very prominent red, nectar guides are clear cut and clear skies are a strong blue. The next map is weighted, roughly, 5to3 on the proportional spectrum each [I,R,G,B,U] component covers as wavelengths. The output shows the nectar guide enough for it to be noticeable, but clearly less so. The last map is my favourite so far, it is a 5to3 map that distributes the [I,R,G,B,U] in equal proportions. It dulls the bright red vegetation caused by infrared in the red channel and shows the nectar guide a little better than the previous map.

 Map Type Channels & Output Classic IR-VIS-UV R: IR G: VIS B: UV Proportional IRGBU R: (IR + IR + (IR * 0.33)) * 0.42 G: ((IR * 0.66) + R + (G * 0.66)) * 0.42 B: (UV + B + (G * 0.33)) * 0.42 Equal IRGBU R: (IR + (R * 0.66)) * 0.60 G: ((R * 0.33) + G + (B * 0.33)) * 0.60 B: (UV + (B * 0.66)) * 0.60

# Testing Infrared Software

This post is to show one of the features of WavelengthPro, some photography software I’m writing at the moment. It’s in early stages at the moment, I hope to add a lot more.

Channel Map Templates
I plan on having a basic and advanced way of mixing channels, so far I’ve done the basic version where you choose template maps. The advanced version will use percent sliders of every channel for every channel just like in Photoshop or GIMP etc. Below is a table showing the three starting images (all taken on a full-spec D70 using 720nm, Hoya UV/IR cut and Baader-U filters) and some of the possible mixtures using the program.

 Infrared Visible Ultraviolet Output image: Mapping information: Applying Auto-WB: IRG 3to3 map [R:ir, G:r, B:g] IRGB 4to3 map [R:ir+(r*0.33), G:(r*0.66)+(g*0.66), B:(g*0.33)+b] * 0.75 IRGB 4to3 map [R:ir, G:(r+g)/2, B:b] IR-VIS-UV 3to3 map [R:ir, G:vis, B:uv] IRGBU 5to3 map [R:(ir+r)/2, G:g, B:(b+uv)/2] IRGBU 5to3 map [R:ir+(r*0.66), G:(r*0.33)+g+(b*0.33), B:(b*0.66) + uv] * 0.60 GBU 3to3 map [R:g, G:b, B:uv] IR/UV 2to3 map [R:ir, G:(ir+uv)/2, B:uv]

# Almost UV Photography

For ages I have wanted to do full-spectrum photography, which captures light from Infrared (IR) all the way to ultraviolet (UV), but the UV aspect of it is bloody expensive! DSLR sensors, both CCD and CMOS, capture light slightly outside the visible spectrum (VIS) but use things like hot mirrors and UV filters to narrow the band closer to 390-700nm. The sensors use channeling methods like a Bayer filter to give us the very useful RGB channels, in this post we will work with extra channels for IR and UV.

I am always looking for cheap alternatives for UV and I thought I’d test out a bit of a long shot – using a UV filter to maths my way to a UV image. To do this I bought a daylight simulating bulb that emits UVA (400-315nm) and some flowers from the local gas station. It’s a simple idea, the extra light that the UV filter blocks must be UV light so if we subtract all the other light we are left with UV.

No Filter – UV Filter = UV ResidueI subtracted each colour separately for each pixel: [r1-r2, g1-g2, b1-b2], it was rather red so I used the red channel for the new R,G and B making a brighter grayscaled image (see below). Then I used that new “UV” image along with the colour image to map channels [GBU to RGB] like the images Infrachrome makes using this technique. For infrared and ultraviolet he uses an adapted camera specifically for full-spectrum, infact he uses two in a fantastical and magical set up. Unfortunately mine didn’t work very well, my first guess was that the lower range of blue light being reflected as there is no sign of a nectar guide. But after consulting a pro UV photographer I was told it is due to infrared-leakage.

I thought I’d do a full spectrum map whilst I had the camera set up so I put on a 950nm IR pass filter and took another shot. In the above image the far right is the channel map of the other three.

# Morph Maths

Boredom results in learning!
So I was messing about on this site: http://www.morphthing.com/ when I thought of an old simple crypto program I wrote, it used matricies to encrypt/decrypt sentences. It used a matrix to encode and the inverse matrix to decode: $ABA^{-1} = BI$
For example, $B$ is the original text, $A$ is the cypher text and that makes $A^{-1}$ the key.

That other letter, $I$, is the Identity matrix and it is the equivalent of 1, $BI = B$ like $1a = a$ so it’s nothing here.

Here is an old screenshot:
Anyway, this relates to the site I was on because I wondered is it possible to extract an image from a morph? Well, my idea was to get one of the images used in a morph and “invert” it, then just morph it again. I decided that i’d use the inverted colours as the inverse. It seemed… logical.

The experiment:
Let $A$ be an image of Avril Lavigne and $E$ an image of Emma Watson.

My hypothesis:
$AE * A^{-1} = E$

 $AE$ $A^{-1}$ $AE * A^{-1}$

It seems that $AA^{-1}$ does not equate the Identity matrix $I$, but instead what I will call grey-noise $G$. This makes sense as the colours are probably being overlayed in translucent layers, as we inverted the colour it would neutralise the picture. It roughly worked but there is ofcourse differences where the morph has moved the original image.

Result:
$AE * A^{-1} \approx EG$