OPENCV Official Document Learning record (10)

Source: Internet
Author: User

Pyramid-shaped image processing (image scaling)

The main use of the two functions: Pyrup and Pyrdown

Here's the code:

1#include <opencv2\opencv.hpp>2#include <iostream>3#include <string>4 5 #pragmaComment (linker, "/subsystem:\" windows\ "/entry:\" Maincrtstartup\ "")6 7 intMax_kernel_length = to;8 9 using namespacestd;Ten using namespaceCV; One  A voidShow (ConstSTD::string&name,ConstMat &img) - { - Namedwindow (name, cv_window_autosize); the imshow (Name, IMG); - } -  - intMainvoid) + { -Mat img = Imread ("lena.jpg"); +     if(Img.empty ()) A         return-1; atShow ("Source", IMG); -Mat tmp=Img.clone (); -Mat DST =tmp; -  -Pyrup (TMP, DST, Size (Tmp.rows *2, Tmp.cols *2)); -Show ("bigger", DST); in  -Pyrdown (TMP, DST, Size (Tmp.rows/2, Tmp.cols/2)); toShow ("Smaller", DST); + Waitkey (); -     return 0; the}

Note that the third parameter of the two functions is of type size, which is an object enlarged, since the image used is 512*512, corresponding to the pyramid image magnification, the enlarged image can not be programmed other than the size of the integer multiples of 2, so for rows*1.5,rows* 7 Wait, these dimensions are going to go wrong. Can only be the original image size multiplied by or except 2 of the positive integer number of powers.

Also note that the magnification shown here is the size of the length and width are magnified, so the above results are:

This means that the original 512x512 image is magnified twice times after the 1024x1024, reduced to 1/2 is 256x256.

Above

OPENCV Official Document Learning record (10)

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.