Cvresize function prototypes
voidconstint interpolation=cv_inter_linear);
SRC: Enter an image. (iplimage)
DST: Output image. (iplimage)
Interpolation: Difference Method:
Cv_inter_nn-Nearest Neighbor Difference value
Cv_inter_linear-bilinear difference value (default use)
Cv_inter_area-resampling using pixel relationships. This method avoids ripples when the image shrinks. Similar to the Cv_inter_nn method when the image is enlarged
Cv_inter_cubic-Cubic difference
The function cvresize changes the image src size to get the same sizes as DST. If you set ROI, the function will support the ROI as usual.
Image scaling using the Resize function when programming with C + +
Resize-Letter Prototype
void Resize (inputarray src, outputarray DST, double fx=0double fy=0 , int interpolation=inter_linear);
Note: Dsize and (fx,fy) cannot be 0 simultaneously
Sample program:
Using UBUNTU14.04+OPENCV 3.1.0
/**------------------------------------------------------------------**//** Description: Contains the header file that the program depends on **//**------------------------------------------------------------------**/#include<opencv2/opencv.hpp>#include<opencv2/highgui/highgui.hpp>#include<opencv2/imgproc/imgproc.hpp>#include<string>/**------------------------------------------------------------------**//** Description: Namespace used by the program **//**------------------------------------------------------------------**/using namespaceCV;using namespacestd;/**------------------------------------------------------------------**//** Description: System Global Constants **//**------------------------------------------------------------------**///The file name of the target image that needs to be placed in the project directoryConst stringTagrimg ="Angelababy.jpeg";//Defining window TitlesConst CharSrcwinna[] ="Srcwindow";Const CharGrywinna[] ="Grywindow";Const CharReswinna[] ="Reswindow";/**------------------------------------------------------------------**//** Description: System global Variables **//**------------------------------------------------------------------**///Zoom in and outDoublescale=0.4;intMainintargcChar**argv) { /** Read and display the original image-----------------------------------------------**/ //Reading PicturesMat srcimg =Imread (TAGRIMG); //Check if Read succeeded if(!srcimg.data) {cout<<"read failed, program aborted"<<Endl; cout<<"Please check the project directory for presence"<<TagrImg<<Endl; return-1; } //Create window to display the original imageCvnamedwindow (Srcwinna, cv_window_autosize); Imshow (Srcwinna, srcimg); /** Image Zoom and display--------------------------------------------------**/ //set the size of a scaled pictureSize Resimgsiz = Size (Srcimg.cols*scale, srcimg.rows*Scale ); Mat resimg=Mat (Resimgsiz, Srcimg.type ()); Resize (srcimg, resimg, Resimgsiz, cv_inter_cubic); //Create a window to display scaled imagesCvnamedwindow (Reswinna, cv_window_autosize); Imshow (Reswinna, resimg); Cvwaitkey (0); return 1;}
Reduce the picture to 0.5 times times:
OpenCV using the Cvresize function or the resize function for image scaling