2009年1月4日 星期日

A Simple Transformation

// If the resource is not from bitmap file but from avi file, then each frame of the output
// will up-side down, I still not find out what reason.

// Example 2-4. Loading and then smoothing an image before it is displayed on the screen


#include "cv.h"
#include "highgui.h"

void example2_4( IplImage *);

int main(int argc,char **argv)
{
 IplImage *image = cvLoadImage( argv[1] );
 example2_4( image );
 cvReleaseImage( &image );
 return 0;
}

void example2_4( IplImage *image )
{
 // Create some windows to show the input
 // and output image in.
 //
 cvNamedWindow( "Example4-in" );
 cvNamedWindow( "Example4-out" );

 // Create a window to show our input image
 //
 cvShowImage( "Example4-in" , image );

 // Create an image to hold the smoothed output
 //
 IplImage *out = cvCreateImage( cvGetSize(image) , IPL_DEPTH_8U , 3 );

 // Do the smoothing
 //
 cvSmooth( image , out , CV_GAUSSIAN , 31 , 31);

 // Show the smoothed image in the output window
 //
 cvShowImage( "Example4-out" , out );

 //Be tidy
 //
 cvReleaseImage( &out );

 // Wait for the user to hit a key, then clean up the windows
 //
 cvWaitKey( 0 );
 cvDestroyWindow( "Example4-in" );
 cvDestroyWindow( "Example4-out" );
}

沒有留言: