Digital Image Processing Basic - geometric conversion (geometry operation)

 In this section we summarize the geometric transformation of digital images, several different from the preceding operation (white balance, gradation conversion, spatial filtering) for the intensity of the pixel, the pixel for geometric transformation of the primary location.

Operation of space including affine (linear) transformation (translation, rotation, stretching, shearing) and a projective transformation. Specific details of each conversion method set forth is not expanded, the operation is to extract the pixel (variable) as a transformation matrix (in fact, is linear algebra linear transformation, from the space station B recommended angle geometries understood Linear Algebra: HTTPS: //b23.tv/BV1ys411472E/p1 ). Each matrix transform space corresponding to one kind, if the operation is a superposition of various matrix corresponding to continue multiplying, the results of multiple linear space constantly acting.


Affine transformation

Translation, rotation, stretching strict 2D linear transformation is a rigid transformation (morphological transformation itself does not occur), the shear can ensure constant parallel lines in FIG. 2D linear transformation in six variables, i.e. the degree of freedom DOF = 6.

2D linear transformation on the following items:

 Specifically:

 (Counterclockwise rotation corresponding to the rotation in the drawing)


 Projection Transformation

 (Still does not guarantee the parallel lines parallel projection transformation) corresponding to the original projection conversion divided by a linear transformation of the linear transformation, projection transformation matrix corresponding to the first two rows in the linear transformation parameters, thus uniform linear matrix of the 3 X 3 transformation and projection transformation, when the last row [0 0 1] is a linear transformation.


 Image Interpolation

The image geometric transformation poses a problem is the pixel value after the conversion may not be an integer, and the pixel values ​​we use in general is an integer, so it is necessary to solve approximate. The key idea is to ensure that the interpolated pixel transformed and the nearest most similar neighbor, furthest neighbor most dissimilar, the more neighbors to consider, the smoother image. General interpolation methods are the following:

 Here to explain the idea bilinear interpolation:

FIG known by the bilinear interpolation using the four adjacent points, is assumed to be a, b, c, d, x conversion after the interval falls within abcd, with vertical and horizontal axis x through the block section, 1,2,3,4 four points respectively.

 Pixel value at one point, two points determined by b a, b, and the closest and should, therefore should give greater weight value b, x1 = (1-α) a + αb, Similarly, we can obtain x2 = (1-β) a + βc, x3 = (1-β) b + βb, x4 = (1-α) c + αd.

Similarly, the results of the pixel value x may be determined by the 23 may be determined by the 14, obtained is the same.

x = (1-b) x1 + vx4 = (1-a) x2 + ax3


 Applications and examples

The most direct example of this section is to image registration.

As another specific geometric transformation chestnut: rotates the image 35 degrees clockwise, the x direction scaling ratio of 0.6, 50 translation, y-direction scaling ratio of 0.8, 15 translation.

Results made as follows (left is the original image, is converted FIG right)

Reference Code (Although the code is relatively simple, but there are many places to make mistakes, mainly matlab slightly different definition of the way) Another: The default interpolation method is linear interpolation

the addpath ( 'E: \ Digital_img_processing \ Lecture_7_dicussion_geometry'); 
Fig imread = ( 'zombie.jpg'); 
Rotate = [cosd (-35) sind (-35) 0; -sind (-35) cosd (-35) 0 ; 001]; 
% counterclockwise rotating -35 degrees about the origin 
Scale = [0 0 0.6; 0.8 0 0; 001]; 
Shift = [50 0. 1; 15 0. 1; 001]; 
TF = affine2d ((Shift Rotate * Scale *) '); 
% need to transpose 
Output = imwarp (Fig, TF); 
Figure; imshowpair (Fig, Output,' Montage '); 
Axis ON; 
the xlabel X; 
ylabel Y;

 

Summary (local error-prone)

① matlab geometric transformation matrix is ​​the transpose of the transformation matrix we define, which with its implementation dependent, so remember to transpose

(Affine2d function of official documents)

In contrast with the coordinates of the image coordinate system of the image ② matlab, as a general digital image origin in the upper left corner, x axis, y-axis to the right, while the y-axis in the matlab, x-axis to the right. This leads us to the need to achieve operational definition clockwise counterclockwise, as defined rotate transformation of chestnuts.

 ③ there is a problem is not mentioned transformation matrix according to a transform operation which has been introduced (i.e. the reverse of the above operation):

In a transformation matrix in matlab example:

 The matrix is the transpose of the transformation matrix, it is good to see the translation (-87.5517, 301.3816), while stretching and rotation are superimposed, before and after using the transformation invariance sin 2 [theta] + COS 2 [theta] = tanθ. 1 or obtained. θ = arctan (-0.7969 / 0.4853 = -58.6596 °)

④ problem radians, the angle made later in matlab function usually one more than radians d (degree), as radians: cos () angular manufactured: cosd (). Radian -> angle: rad2deg () angles -> radians: deg2rad ().

 

ref:

matlab in image coordinate system:  https://blog.csdn.net/Enjolras_fuu/article/details/66530196

Guess you like

Origin www.cnblogs.com/pear-linzhu/p/12557368.html