Sampling and down-sampling the image opencv-

 

 

 

Image pyramid

      Image pyramid is a multi-scale image expression, is an effective but simple concept to explain the multi-resolution structure images. An image pyramid is a series arrangement of pyramid shape gradually reduce the resolution, and the one derived from the same set of original images of FIG. By sampling echelon get down until it reaches a termination condition did not stop sampling. We will likened pyramid image layer by layer, the higher the level, the smaller the image, the lower the resolution.

Down-sampling , that is, to reduce the number of sampling points. For an image of N * M, if downsampling factor of k, i.e., it is in the picture  per row and at intervals of k dots a point to take an image. Downsampling easy to implement. 
Liter sample , also known as interpolation. For images that is two-dimensional interpolation. If the up-sampling factor k, i.e. with the original n n + k-1 is inserted between a point two points, it constitutes k points. That is also the two-dimensional interpolation interpolation for each column after each line finished plug. 
The method of interpolation divided into many, generally mainly in time domain and frequency domain two viewpoints. For time-domain interpolation, it is the most simple linear interpolation. In addition, Hermite interpolation, spline interpolation, etc. can be found from the relevant numerical formula book, it can be directly substituted into operation. For frequency-domain, according to the nature of Fourier transform can be seen, equivalent to zero padding the time domain to the frequency domain interpolation. So, how much can be achieved interpolation operation in the frequency domain by zero padding.

Gaussian pyramid sampling relevant API 
sampling (1) (cv :: pyrUp) - zoom (zoom in), the bottom end of the development 

pyrUp (Mat src, Mat dst, Size (src.cols * 2, src.rows * 2)) ; // generated image is the original width and height of each amplified twice 

pyrUp (src, dst, Size ( src.cols * 2, src.rows * 2)); // the sample 


(2) downsampling (cv :: pyrDown) - reduction (zoom out), to the tip development 

pyrDown (Mat src, Mat dst, Size (src.cols / 2, src.rows / 2)); // generated image is the original width and height each reduced 1/2 

pyrDown (the src, dst2, Size (src.cols / 2, src.rows / 2)); // downsampling

Gaussian pyramid - downsampling

    • Gaussian pyramid from the bottom up, layer by layer downsampling achieved, not the cross-domain layer;
    • Deletes the current layer even rows and columns to get on the floor after downsampling images;
    • After down-sampling the image size before an image size . 1 . 4 14;
    • Gaussian pyramid generation steps: 
      • ① Gaussian blur;
      • ② delete the even-numbered rows and columns.

 

 

 

#include <opencv2 / opencv.hpp> 
#include <the iostream> 
#include <math.h> 
the using namespace cv; // use cv namespace 
int main (int argc, char ** argv) {// argc represents the command line the number of parameters (separated by whitespace), argv stores all command line parameters 
	Mat the src, DST, dst2; 
	the src = imread ( "E: \\ \\ vs2015 VS2015Opencv Project \\ \\ \\ 091 Picture. JPG "); 
	IF (src.empty ()) { 
		the printf (" Could Not Load Image ... \ n-"); 
		return -1; 
	} 
	namedWindow (" INPUT Image ", CV_WINDOW_AUTOSIZE); 
	imshow (" INPUT Image ", the src); 
	sample / * a * / 
	pyrUp (the src, DST, Size (src.cols * 2, src.rows * 2)); // upsampling 
	imshow ( "the UP Image", DST); 
	/ * * downsampling /  
	pyrDown (the src, dst2, Size (src.cols / 2, src.rows / 2));// downsampling
	imshow ( "DOWN Image", dst2);
	/ * Gauss different DOG * /
	Gray_src MAT, G1, G2, dogImg; 
	cvtColor (the src, gray_src, CV_BGR2GRAY); // gray 
	GaussianBlur (gray_src, g1, Size ( 5, 5), 0, 0); // Gaussian blur 
	GaussianBlur (g1, g2, Size (5, 5), 0 , 0); // Gaussian blur again 
	subtract (g1, g2, dogImg, Mat ()); // subtract g1-g2 (low - high), Gaussian difference stars the gradation value is low, the image is dark 
	normalize (dogImg, dogImg, 255, 0, NORM_MINMAX); // display normalized (normalized 0 is less than 0, that is greater than 255 255), maximum value of 255, the minimum value 0, minimum maximum type 
	imshow ( "DOG Image", dogImg); 
	waitKey (0); 
	return 0; 
}  

Reference article:

https://blog.csdn.net/qq_25343557/article/details/78694722

https://zhuanlan.zhihu.com/p/40489916

Guess you like

Origin www.cnblogs.com/fcfc940503/p/11482783.html