Image pyramids can be used to manipulate the scaling of images.
There are two widely used image pyramids: The Gaussian pyramid and the Laplace pyramid.
The Gaussian pyramid is introduced here.
The Gaussian pyramid operates in two ways: Upsample and downsample, which can be understood as the enlargement and reduction of the image.
Consider the example:
If the image is downsample, both Col and row become the previous 1/2, and the area of the image is 1/4. The number of layers equivalent to the pyramid rises to the first layer, with an area of previous One-fourth.
If it is upsample, both Col and Row are twice times the previous, and the image area is 4 times times the previous one. Equivalent to the pyramid descending one layer.
The steps of downsample in the Gaussian pyramid:
1. Convolution the image with a Gaussian core. The Gaussian nucleus can be of the following size:
2. Remove even-numbered rows and even columns.
Similarly, the upsample steps in the Gaussian pyramid:
1. Insert a new row, a new column, and a new pixel to zero for each row and column in the image.
2. Convolution the enlarged image with a Gaussian core. This Gaussian core is 4 times times the downsample to compensate for the loss of information from the new pixel.
The Pyrdown and Pyrup functions are given in OPENCV to implement the functions of Downsample and Upsample:
void Pyrdown(inputarray src, outputarray DST, const size& dstsize= Size (), int bordertype=border_default )
Parameter dstsize is generally size (SRC.COLS/2, SRC.ROWS/2)
void Pyrup(inputarray src, outputarray DST, const size& dstsize =size (), int bordertype=border_default )
Parameter dstsize is generally size (Src.cols * 2, Src.rows * 2)
OpenCV Notes (10)--Image pyramid