opencv--image Scaling-resize () __opencv

Source: Internet
Author: User

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; }


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.