#include "cv.h"

#include "highgui.h"

IplImage* doPyrDown(

  IplImage* in,

  int       filter = IPL_GAUSSIAN_5x5)

{

    // Best to make sure input image is divisible by two.

    //

    assert( in->width%2 == 0 && in->height%2 == 0 );

    IplImage* out = cvCreateImage(

        cvSize( in->width/2, in->height/2 ),

        in->depth,

        in->nChannels

    );

    cvPyrDown( in, out );

    return( out );

};

int main( int argc, char** argv )

{

  IplImage* img = cvLoadImage( "lena.jpg" );

  IplImage* img2 = cvCreateImage( cvSize( img->width/2,img->height/2 ), im$

  cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE );

  cvNamedWindow("Example2", CV_WINDOW_AUTOSIZE );

  cvShowImage("Example1", img );

  img2 = doPyrDown( img );

  cvShowImage("Example2", img2 );

  cvWaitKey(0);

  cvReleaseImage( &img );

  cvReleaseImage( &img2 );

  cvDestroyWindow("Example1");

  cvDestroyWindow("Example2");

}

I#python code

import cv2.cv as cv

import cv2

if __name__ == '__main__':

    import sys

    try:

        image_in = sys.argv[1]

    except:

        image_in = "lena.jpg"

        print "Welcome, YouTube!"

    try:

        olim = int(sys.argv[2])

    except:

        olim = 2

    image = cv2.imread(image_in, cv.CV_LOAD_IMAGE_COLOR)

    image_copy = image.copy()

    for i in range(olim):

        image_copy = cv2.pyrDown(image_copy)

    display_image = cv2.resize(image_copy, (image.shape[1], image.shape[0]$

    cv2.imshow("Input Image", image)

    cv2.imshow("Result", image_copy)

    cv2.imshow("Blurred Image", display_image)

    cv.MoveWindow("Input Image", 10, 10)

    cv.MoveWindow("Result", image.shape[1] + 20, 10)

    cv.MoveWindow("Blurred Image", image.shape[1] + image_copy.shape[1] + $

    cv2.waitKey()