Shift to Minimise Differences

Shift to Minimise Differences

This option provides a method of evaluating the local translation required to optimise the matching between two images. There is a choice of two basic techniques: minimise the difference between two images, or maximise the correlation between the two. The first of these is computationally much faster, as the onboard ALU may be utilised for most of the required manipulations. It is an effective technique where the illumination is relatively uniform. In contrast, maximising the cross correlation is able to cope with nonuniform illumination, but at the expense of much more computation. Note that we evaluate th cross correlation directly (ie. we do not employ FFTs) using integer arithmetic as this proves more convenient and faster if we are considering only a limited number of displacements.

For both techniques the difference/correlation is evaluated with up to 255 different translations horizontally and vertically. The resultant image is smoothed using a fast low pass filter, before being compared pixel-by-pixel with the shifts already computed to determine which shift is optimal. The optimal shift has a pixel resolution (cf. [P Particle image velocimetry] provides subpixel resolution).

One use of this feature is to provide a high spatial resolution/low velocity resolution particle image velocimetry (PIV) measurement for flows with very high particle concentrations. Normally two-frame PIV is performed by maximising the cross correlation function between regions in the two images. While this is a robust procedure, it is computationally very expensive. Provided you have relatively uniform illumination, then minimising the absolute or square difference between the two images will produce approximately equivalent results in only a fraction the time by employing the onboard ALU to perform most of the calculations.

The current technique may also be applied to double-pulsed single frame images. The restrictions on these are similar to those imposed on normal double pulsed single frame PIV, namely that there must not be any regions with a velocity close to zero: the two images of the same particle must appear distinct in the images to be analysed. The search limits for the optimal shift must not include a 0,0 shift (otherwise this will always be the optimal!).

Note that the option [P Particle image velocimetry] is optimised for this form of computation. It utilises a more sophisticated optimisation criterion to provide subpixel resolution for the translation, and offers the possibility of producing a Trk2DVel compatible grid file.

First source buffer ?

The response to this prompt specifies the buffer containing the image to be used as the base image for the optimal shift. Any valid buffer may be specified. The contents of the specified buffer is swapped with buffer 1 at the start of the computation, and swapped back at the end. This swap is undertaken to ensure the source buffer is onboard. Note that if <ctrl><C> is used to abort DigImage, then the buffers may not be restored (they are restored if <escape> is used).

Second source buffer ?

The response to this prompt specifies the buffer containing the image to be used as the shifted image (ie. the one to which the translation is applied before being directed to the B arm of the ALU) for the optimal shift. Any valid buffer may be specified. The contents of the specified buffer is swapped with buffer 2 at the start of the computation, and swapped back at the end. This swap is undertaken to ensure the source buffer is onboard. Note that if <ctrl><C> is used to abort DigImage, then the buffers may not be restored (they are restored if <escape> is used).

Place optimal vertical displacement in which buffer ?

This entry specifies the buffer in which the optimal vertical displacement will be stored. This displacement is given by the intensity of pixels in the buffer, offset by 128 so that zero displacement will have an intensity of 128, +2 pixels 130, -4 pixels 124 etc. Note that negative displacements are upwards (ie. we are using pixel coordinates).

Place optimal horizontal displacement in which buffer ?

This entry specifies the buffer in which the optimal horizontal displacement will be stored. This displacement is given by the intensity of pixels in the buffer, offset by 128 so that zero displacement will have an intensity of 128, +2 pixels 130, -4 pixels 124 etc.

Produce vector plot on which buffer ?

DigImage also produces a vector plot indicating the optimal displacements for the pair of images. The vector plot is produced on a grid (the size of which depends on the displacements) overlaying the current contents of the specified buffer. This buffer may be one of the source buffers. The vector plot is made AFTER the buffers have been restored to their original locations. Vectors are plotted with an intensity of 128, except for their starting point which is plotted with intensity 255. Note that the length of the vectors is equal to the optimal displacement.

Erase current contents of vector plot buffer ?

Answering yes (<Y>) will erase the contents of the buffer specified by the previous entry. No (<N>) will cause the vector plot to be overlayed on top of the required buffer.

Displacement vector scale (1 for actual displacement) ?

This entry allows you to specify the scale of the arrows to be drawn on the vector plot. A value of 1 will show the actual displacement, 2 twice the displacement etc. Note that as the displacements are measured with an accuracy on one pixel, a value of 2 will produce lines in steps of two.

On completion DigImage will display buffer 0 which will contain the optimal absolute difference (squared) image. If you wish to keep this image, you must copy it across to another buffer.

Minimum vertical shift ?

This entry specifies the minimum vertical translation to be tested for. The translation is given in pixels.

Maximum vertical shift ?

This entry specifies the maximum vertical translation to be tested for. The translation is given in pixels. Up to sixteen different equally spaced translations will be used to span the specified minimum/maximum translation in steps of one or more pixels.

Minimum horizontal shift ?

This entry specifies the minimum horizontal translation to be tested for. The translation is given in pixels.

Maximum horizontal shift ?

This entry specifies the maximum horizontal translation to be tested for. The translation is given in pixels. Up to sixteen different equally spaced translations will be used to span the specified minimum/maximum translation in steps of one or more pixels.

Use Square or Absolute value of intensity difference, or Cross correlation ?

The choice here dictates whether the absolute difference łA-Bł or the square of the difference (A-B)ę is minimised, or the cross correlation is maximised. The first two are computationally more efficient and use a differencing technique which works well provided th illumination is approximately uniform. Absolute differences (<A>) are more robust to entities (eg. particles) entering or leaving the image, but will be more sensitive to noise than the square difference. The cross correlation (<C>) is robust to spatial variations in light intensity, but is computationally much more expensive.

{If Cross correlation chosen}

Vertical size of correlation cell ?

This entry specifies the vertical size of the cell over which the cross correlation coefficient between the two images is evaluated. The cell size is taken as odd and is centred on the pixel. Larger cells take longer to compute, and provide a greater degree of spatial filtering.

{If Cross correlation chosen}

Horizontal size of correlation cell ? [Cross correlation only]

This entry specifies the horizontal size of the cell over which the cross correlation coefficient between the two images is evaluated.

{If Square of difference chosen}

Divide difference by image mean ?

Selecting this option (<Y>) effectively bases our optimisation criterion on a Chi-square test. Rather than using łA-Błę, we use łA-Błę/[«(A+B)]. This statistic will be somewhat less sensitive to variations in illumination, but at the cost of nearly double the computation for each shift. An answer of no (<N>) will cause the simple łA-Błę to be used.

{If Square of difference divided by mean chosen}

Buffer for temporary storage of difference ?

This prompt will be produced only if division by the mean has been selected. The buffer specified in response to this prompt will be used to temporarily store the difference image while the mean image is computed by the ALU. The difference will be divided by the mean, and then stored in buffer 0 for filtering before comparison with the previous optimal.

{Absolute difference chosen}

Divide difference by image mean ? [Absolute difference]

An answer of yes (<Y>) to this question will mean that DigImage will attempt to optimise łA-Bł/[«(A+B)], the relative absolute difference in the two images. By including the division by the mean, the result will be less sensitive to variations in the illumination, but at the cost of approximately double the computation. No (<N>) allows the simple łA-Bł to be employed.

{If absolute difference divided by mean chosen}

Buffer for temporary storage of difference ?

This prompt will be produced only if division by the mean has been selected. The buffer specified in response to this prompt will be used to temporarily store the difference image while the mean image is computed by the ALU. The difference will be divided by the mean, and then stored in buffer 0 for filtering before comparison with the previous optimal.

Kernal size for filtering difference/correlation ?

This entry specifies the size of the low pass convolution kernal to be applied to the difference or correlation image. The filter used is the same as for [;FL Fast low pass filter] and has the effect of reducing noise and averaging the shifts over a given region. The selected filter should be an odd number in the range 3 to 25.

Number of passes of the filter ?

The filter specified by the previous entry may be applied more than once to the difference or correlation image. This entry specifies the number of times it is to be applied.

Kernal size for filtering displacement indices (<3 to suppress) ?

If a value less than 3 is specified, then no filtering is undertaken on the displacement index buffers. If the value specified is 3 or greater, then the corresponding fast convolution filter (using the [;FL Fast low pass filter] set) is applied to the vertical and horizontal displacement index buffers. This filtering is undertaken before the displacement vector plot is produced. This filter may be employed to reduce the occurance of bad displacement vectors in poorer quality images (although it should be noted that it will introduce some error to otherwise good vectors in addition to reducing the spatial resolution).

Parent menu

Main Menu

DigImage User Documentation


Stuart Dalziel, last page update: 19 February 1996