Fondazione Bruno Kessler - Technologies of Vision

contains material from
Template Matching Techniques in Computer Vision: Theory and Practice
Roberto Brunelli 2009 John Wiley & Sons, Ltd

2.1 Image distortions

Real optical systems are usually affected by geometrical distortions whose type and amount varies significantly from barely visible to significant. Furthermore, some characteristics of light propagation in an optical system results in unavoidable effects, such as wide angle lens vignetting. In this section we will look at a few TeMa functions that can be used to simulate geometrical distortions and vignetting effects.

The first step is to get some perfect images. A simple and cheap way to obtain such images is to generate them using a ray tracing system. Package TeMa includes some testing images generated using the Persistence of Vision Ray Tracer (http://www.povray.org).

1 tiffdir          <- file.path(system.file(package="TeMa"), 
2 ...                               "sampleimages/cameraSimulation") 
3 # normalize pixel value range to [0,255] 
4 i_ortho          <- ia.scale( 
5 ...                        ia.readAnimage( 
6 ...                           file.path(tiffdir,"ortho_iso12233_large.tif")), 
7 ...                              maxValue = 255) 
8 # get the red color channel 
9 i_orthoRed       <- i_ortho[[1]] 
10 # and extract an image portion 
11 i_orthoRedDetail <- ia.get(i_orthoRed, animask(0,0,1201,256))

As detailed by Equations TM:2.26-27 geometrical distortions can be considered as image plane effects and can be accurately simulated once the distortion curves are specified. Detailed distortion information is often available for high quality lenses directly from the manufacturer or can be measured using calibration patterns. The following code snippet shows to curves based on the public data for a real wide angle lens: the percent distortion and the vignetting are reported as a function of the distance expressed in millimeters from the optical center of the lens designed for a standard 24 × 36mm frame. The distortion and vignetting curves are obtained using spline interpolation given a set of manually measured points.

1 sampleDistortion<-splinefun(c(0, 5.00,10.00,11.90,15.00,18.30,20.00,21.60), 
2 ...                           c(0,-0.41,-1.55,-2.00,-2.45,-2.00,-1.18,-0.11)) 
3 sampleVignette  <-splinefun(c(0, 5.00,10.00,15.00,20.00,21.60), 
4 ...                           c(1, 0.86, 0.64,0.41,0.23,0.18))

Inspection of the distortion curve, reported in Figure 2.1, shows it to be of a complex type, exhibiting both barrel distortion (up to 15mm from the optical center) and pincushion distortion (from 15mm onwards).

1 tm.plot("figures/sampleDistortion", 
2 ...        plot(1:21, sampleDistortion(1:21), 
3 ...        type="b", xlab="mm", ylab="Distortion"), 
4 ...        grid())


PIC

Figure 2.1: A sample distortion curved based on the data for a high quality real lens. The curve tells us that this lens exhibit both barrel and pincushion distortion.


Generating a vignetted image is a simple task using the functions provided by TeMa:

1 vMap   <- tm.computeVignettingMap(width=1201, height = 801, 
2 ...                               curve = sampleVignette) 
3 vImage <- tm.vignetteImage(i_orthoRed, vMap) 
4 tm.plot("figures/vImage", ia.show(vImage)) 
5 tm.plot("figures/vDeltaProfile", 
6 ...        plot(vImage@data[475,]-i_orthoRed@data[475,], 
7 ...        type="l",ylab="Delta",xlab="X"))

The results are reported in Figure 2.2. A distorted image can be generated in a similar way

1 dMaps  <- tm.computeDistortionMaps(width=1201, height = 801, 
2 ...                                curve = sampleDistortion) 
3 dImage <- tm.distortImage(i_orthoRed, dMaps)

A vignetted distorted image can be generated easily

1 vdImage <- tm.vignetteImage(dImage, vMap)


PIC
PIC

Figure 2.2: Vignetting appears as a (proportional) intensity reduction whose entity increase from the center towards the boundary of the frame. The plot highlights the difference from the perfect image along a row in the middle of the image. It is apparent that vignetting can have a significant impact on template matching techniques.