Monday, 11 November 2019

Chromatic aberration in digital photographs

In my last post I wrote about my attempts to measure vignetting in the lenses I use with my DSLR camera. Another lens problem that the camera can correct (but only for Canon lenses) is lateral chromatic aberration.

To determine the amount of correction my lenses need I printed out a simple test chart and photographed it at a variety of focal lengths. I also tried different apertures, but the correction required does not vary with aperture. Here is one of my photographs.

Chromatic aberration tests

I tried to write some software to measure any disparity between red, green, and blue images, but failed to achieve anything usable. I settled for judging the error by eye using this simple Pyctools network.


The "reader" component has options to scale the red and blue images to minimise chromatic aberration. By adjusting the scale values and then re-running the graph I was able to find good values for each of my lenses, at several focal lengths for the zoom lenses. The "UVgain" stage makes it easier to see the aberration. Multiplying the U signal by zero and the V signal by 8 or 16 makes it much easier to tune the red scaling, and vice versa to tune the blue.

I've now reached the stage where I can process my "raw" camera images and get better looking results than from the camera's internal processing. I've combined all my chromatic aberration and vignetting measurements into an easy to use Python script. I expect to continue to improve it in future.

Tuesday, 22 October 2019

Digital photograph vignetting revisited

A few years ago I wrote about some experiments I'd done with measuring and correcting vignetting in digital photographs. (Some cameras have such correction built in, called "peripheral illumination correction" or similar.)

I recently purchased a second-hand 10-18 mm wide angle lens for my DSLR. Measuring its vignetting using my previous method is difficult as it has a field of view in excess of 100°. It's hard to provide an evenly illuminated target this large. The answer is to assume the lens has no vignetting at its smallest aperture, and use an image at this aperture as a reference when measuring the vignetting.

I set up the camera on my dining room table with an A4 sheet of translucent Perspex (or similar) an inch or so in front of the lens hood. The camera was facing towards the window, but no other lighting was used.

This is a photo taken at 10mm focal length and maximum aperture, ƒ/4.5.
Vignetting tests

At minimum aperture, ƒ/22, the result doesn't look much different, apart from a bit of fluff on the front of the lens being more nearly in focus.
Vignetting tests

Dividing the ƒ/4.5 image by the ƒ/22 (after converting both to luminance) gives this image.
Vignetting tests

This may not appear to have much vignetting, but my analysis and curve fitting suggests otherwise.
Vignetting tests

The fitted function (shown in orange) is a polynomial in r², r⁴, and r⁶. Using even powers of r ensures the function has zero slope at r=0. The correction required is about half an ƒ-stop (factor of 1.41) at the corners.

Running the process for narrower apertures shows the expected reduction in vignetting.
Vignetting tests

I think the  "measured" curves show some similarity, but a 3rd order polynomial (in r²) is not a good match at smaller apertures. There's also no obvious trend in the polynomial coefficients, so I can't confidently predict the correction required at other apertures. I'd like to find a better fitting function, but I think this is beyond my mathematical abilities.

PS I've just tried fitting a power function 1.0 + (a * (x ** b)) instead of a polynomial and instantly got better looking results.
Vignetting tests

Wednesday, 11 September 2019

Shaun the Sheep

I'm a huge fan of the Aardman Animation children's TV series "Shaun the Sheep". Although it's nominally a children's programme there is a lot in it for adults as well. I particularly like the references to things that not many children would be aware of. Here are a few that I've spotted. I'll add more when I find them.

All images ©Aardman / BBC / WDR.

"Supersize Timmy" (S2, E09)

This episode borrows a lot from "King Kong".


"Let's Spray" (S3, E05)

Timmy's graffiti looks like a "Banksy" to me. (Note - this episode is not broadcast in the UK as it might encourage vandalism. The still is from German TV.)


"Hard To Swallow" (S3, E08)

A birdwatcher points his binoculars at a pair of crows. One of them turns and grins in a way that reminds me of Eric Morecambe.


"Missing Piece" (S4, E14)

The jigsaw is a bit like Constable's "The Hay Wain".  Or maybe not. Please yourselves.


"Turf Wars" (S5, E11)

This episode climaxes with a lovely homage to Eisenstein's "Battleship Potemkin".


"Happy Farmers' Day" (S5, E16)

The sheep cook a meal for the farmer, but various mishaps delay the dessert. Bitzer provides some entertainment, perhaps inspired by Manuel and Polly in "Fawlty Towers".