- Parametric geometric transformation principle of image
Image geometric transformation is also called image space transformation, which maps coordinate position in one image to new coordinate position in another image. The key to our study of geometric transformation is to determine the spatial mapping relation and the transformation parameters in the mapping process. Geometric transformation does not change the pixel value of the image, but rearranges the pixels on the image plane. A geometric transformation requires two operations: first, the operations required by the spatial transformation, such as translation, rotation and mirror image, need to use it to represent the < pixel > mapping relationship between the output image and the input image. In addition, grayscale interpolation algorithms are required, because the pixels of the output image may be mapped to the non-integer coordinates of the input image when calculated according to this transformation relationship.
- Image forward transformation and image reverse transformation
The essence of image transformation is to map the coordinate of pixel point to another position through some kind of function relation. Let’s say I(x,y), and I ‘(x’,y ‘), Is saved in the following relationship between before and after the transformation of the image (x ‘y’) = (f (x, y) g (x, y)) I (x, y) = I ‘(‘ x, y’) = I ‘(f (x, y), g (x, y)) (1) (x, y) = (f – 1-1 (x ‘, ‘y) g (x’, ‘y)) I’ (‘ x, y ‘) = I (x, y) = I (f – 1 (x ‘, ‘y), g (x’, ‘y) – 1) (2) formula (1) the original image are known to the target image coordinate transformation (f (x, y), g (x, y)), Therefore, we can know the position of a point in the original image in the target image after transformation, which is called forward mapping. On the contrary, in Formula (2), we know the position (f−1(x ‘,y ‘),g−1(x ‘,y ‘)) of a point (x ‘,y ‘) in the target image before transformation on the original image, which is called backward mapping. Integer point coordinates on the input image become non-integer point coordinates when mapped to the output image. Therefore, there will be a lot of input image pixels mapped around the integer point pixel value. Each non-integer point pixel value around it will be assigned a certain gray value to it. The superposition of these allocated pixel values is the pixel value of the integer point position of the output image. Because of this distributive, superimposed nature, forward mapping is sometimes called pixel transfer mapping. For forward mapping, the pixel value of a certain point in the output image cannot be obtained directly. It is necessary to traverse all pixel values of the input image, perform coordinate transformation, and allocate pixel values to integer positions to obtain the pixel value of each pixel point in the output image. This is the disadvantage of forward mapping.
Backward mapping is straightforward. In this case, we know the integer point position (x ‘,y ‘) on the output image is located on the input image (x, Y) before transformation. Generally speaking, this is a non-integer point position, and the pixel value of this point is obtained by interpolation with the input image pixel value of the integer point position around it. After traversing the output image, we can calculate its pixel values one by one through coordinate transformation and interpolation. Therefore, backward mapping is also called image filling mapping. As shown in the figure below.
- Image under sampling principle and image interpolation method principle
The primary purpose of minimizing an image (also called subsampled or downsampled) is twofold: 1) To make the image conform to the size of the display area; 2. Generate thumbnails of corresponding images. The primary purpose of amplifying an image (also known as upsampling or interpolating) is to amplify the original image so that it can be displayed on a higher-resolution display device. Scaling an image does not give you much information about the image, so the quality of the image will inevitably suffer. However, there are some scaling methods that can increase the amount of information in an image so that the quality of the scaled image exceeds that of the original image. Down-sampling principle: For an image I size MN, it is sampled s times down, that is, the resolution image of (M/s)(N/s) size is obtained. Of course, S should be the common divisor of M and N. If the image is in matrix form, it is to turn the image in the window of the original image S * S into a pixel. The value of this pixel point is the mean value of all pixels in the window: Upsampling principle: image amplification is almost always interpolation method, that is, on the basis of the original image pixels, appropriate interpolation algorithm is used to insert new elements between pixels.
- Complete the geometric transformation experiment of the image
An image is made up of pixels, and the collection of pixels is like a two-dimensional matrix, each pixel has a “position”, that is, each pixel has a coordinate. Assuming that the original pixel position coordinates are (x0,y0), after the translation (△x, △y), the coordinates become (x1,y1) can be expressed as: X1 = x0 + △x, y1 = y0 + △y; Expressed by the matrix:
im = imread('D:/ CVPR/job 1/ experiment 1/ test.jpeg'); % read a graph [H,W,Z] = size(im); % get image size I=im2double(im); % Convert the image type to double res = zeros(H,W,Z); % construct the result matrix. Each pixel is initialized by default to1(white) delX =50; % translation X delY is equal to100; % translation Y tras = [1 0 delX; 0 1 delY; 0 0 1]; % shift matrixfor x0 = 1 : H
for y0 = 1 : W
temp = [x0; y0; 1]; Temp = round(tras * temp); % According to the algorithm, matrix multiplication: transformation matrix multiplied by the original pixel position x1 = temp(1.1); % new pixel x1 position, new row position y1 = temp(2.1); % the new pixel y1 position, that is, the new column position % after the transformation of the position to determine whether out of boundsif (x1 <= H) & (y1 <= W) & (x1 >= 1) & (y1 >= 1Res (x1,y1,:)= I(x0,y0,:); End end set()0.'defaultFigurePosition'[100.100.1000.500]); % window size set(0.'defaultFigureColor'[1 1 1]); % Set window color figure; % Opens a window to display (multiple) image subplot(1.2.1), imshow(I),axis on ; % display image, one row, two columns, first subplot(1.2.2), imshow(res),axis on; % display picture, one line, two columns, secondCopy the code