|
|||
![]() ![]() |
Interactive Java TutorialsDigital Image WarpingGeometrical distortion of objects appearing in a digital image can take various forms. One algorithm that can correct certain types of geometric distortion in digital images is the geometrical warping transformation algorithm. This interactive tutorial explores geometrical warping algorithms for correcting certain types of distortion in digital images. The tutorial initializes with a randomly selected specimen image appearing in the left-hand window entitled Source Image. Adjacent to the Source Image window is a Destination Image window that displays a warped projection of the captured image. To operate the tutorial, select an image from the Choose an Image pull-down menu. The yellow quadrilaterals in each window control the operation of the warping transformation. To adjust the shape of the yellow quadrilaterals in either window, drag and drop any of their control points to a position within the same window. The control points are the small blue circles that form the vertices of the quadrilateral. To move a control quadrilateral, drag and drop it to another position in the same window. The control quadrilaterals may also be rotated by clicking and dragging the mouse along their outer boundaries. Whenever a quadrilateral is changed, the Destination Image will be recomputed and redisplayed automatically. The warped image will be constructed from the Source Image according to the shapes and positions of the yellow control quadrilaterals. Visitors should examine the appearance of the Destination Image while reshaping the quadrilaterals in both the Source Image and Destination Image windows. Geometric warping is a useful technique for removing some types of regularly occuring distortion from images in several specialized areas of digital micrography and imaging. For example, trapezoidal distortion is often encountered in scanning electron microsope imaging, where the specimen is often tilted to enhance the contrast in the captured image. This situation is not often encountered in light microscopy since the depth of field is typically so low that specimens must be flat and normal to the optical axis for proper imaging. This situation does arise, however, in the case of aligning serial section images, where foreshortening in sliced biological specimens can range from 5 to 15% in the direction of cutting due to the compression of the specimen by the cutting knife. The type of geometric warping demonstrated in this tutorial is a projective mapping of a quadrilateral into a quadrilateral. This type of warping is useful for correcting the trapezoidal distortion, foreshortening, and alignment defects described above. This method is not suitable for correcting curvature defects of the imaging system, however, for which higher order warping is required. The general form of a projective mapping is a rational linear mapping. The relationship between source and destination space is given by the following equations:
where x and y represent the coordinates of a point in the source image, and u and v represent the coordinates of a point in the destination image. The coefficients a, b, c, d, e, f, g, and h (i represents a homogeneous coordinate and is commonly set to 1) in the equations above can be obtained by solving the following system of linear equations: ![]() In the matrix equation above, (xi, yi), i = 0, 1, 2, 3, represent the coordinates of the control points of the source quadrilateral, and (ui, vi), i = 0, 1, 2, 3, represent the coordinates of the control points of the destination quadrilateral. The solution of this system of equations requires the inversion of an 8 x 8 matrix, which can substantially increase the amount of programming effort required for an application that uses this method. With a CPU that provides adequate floating point performance, this method has the advantage of allowing for real-time computational performance. When this system of linear equations is solved, the address of a pixel contained within the quadrilateral of the Source Image may be computed for each pixel in the Destination Image using equations (1) and (2) above. Unfortunately, the calculated coordinates for the location of the pixel in the source image will only rarely be integers. The result is that the calculated pixel location often lies in an area between a group of pixels in the source image. Several methods are available to deal with this problem. The simplest approach is the nearest neighbor algorithm, which operates by truncating the calculated coordinates so that the fractional part of the address is discarded. Another very similar approach is to round the calculated coordinate values to the nearest integer value. Either method introduces a small degree of error that will slightly distort the destination image. In some cases this distortion is acceptable, but better results can usually be obtained by interpolating brightness values over a small neighborhood of pixels at the expense of more detailed computations. The method of bilinear interpolation employs a four-pixel neighborhood (2 x 2 array) surrounding the calculated address to obtain a new transformed pixel value. In the tutorial, the intensity values of the pixels in the Destination Image are computed using the nearest neighbor algorithm by default. Included in the tutorial is an option to apply bilinear interpolation (the Bilinear Interpolation checkbox) to the warped image instead of the nearest neighbor algorithm. Checking this option will make the warped Destination Image appear smoother, improving the visual quality of the resulting image. BACK TO DIGITAL IMAGE PROCESSING TUTORIALS Questions or comments? Send us an email.
Text and graphics for this interactive tutorial are
|
||
![]() ![]() |