The main introduction function resize ();
The image scaling effect is shown below:
The main program code and function explanations are as follows:
/************************************************************************//* OpenCV image Scaling uses the function: Resize void resize ( Inputarray src, outputarray DST, Size dsize, double fx=0, double fy=0, int interpolation=inter_linear) parameter meaning: Inputarray s RC-Original image Outputarray DST-output image size dsize-size of the target image double fx=0-scaling on the x-axis double fy=0-scaling on the y-axis proportional int interpolation-interpolation mode, there are four ways to inter_nn-nearest neighbor interpolation Inter_linear-bilinear interpolation (default use) Inter_area-resampling with pixel relationships, when the image is reduced, the method You can avoid ripple occurrences.
When the image is enlarged, it is similar to the Inter_nn method.
Inter_cubic-cubic interpolation. Description: Dsize and FX and FY must not be at the same time zero *//************************************************************************/#include <
Opencv2\opencv.hpp> #include <opencv2\imgproc\imgproc.hpp> using namespace CV;
int main () {//Read image Mat Srcimage=imread ("1.jpg");
Mat Temimage,dstimage1,dstimage2;
Temimage=srcimage;
Display the original imshow ("original", Srcimage);
Size Adjustment Resize (temimage,dstimage1,size (TEMIMAGE.COLS/2,TEMIMAGE.ROWS/2), 0,0,inter_linear); Resize (Temimage,dstimage2,Size (temimage.cols*2,temimage.rows*2), 0,0,inter_linear);
Imshow ("Narrowing", dstImage1);
Imshow ("enlarge", dstImage2);
Waitkey ();
return 0; }