This tutorial assumes the reader:
(1) Has a basic knowledge of Visual C++
(2) Has some familiarity with computer vision concepts
(3) Has read the previous tutorials in this series
The rest of the tutorial is presented as follows:

int high_switch_value = 0;
int highInt = 0;
int low_switch_value = 0;
int lowInt = 0;
void switch_callback_h( int position ){
highInt = position;
}
void switch_callback_l( int position ){
lowInt = position;
}
int _tmain(int argc, _TCHAR* argv[])
{
const char* name = "Edge Detection Window";
// Kernel size
int N = 7;
// Set up images
IplImage* img = cvLoadImage( "MGC.jpg", 0 );
IplImage* img_b = cvCreateImage( cvSize(img->width+N-1,img->height+N-1), img->depth, img->nChannels );
IplImage* out = cvCreateImage( cvGetSize(img_b), IPL_DEPTH_8U, img_b->nChannels );
// Add convolution boarders
CvPoint offset = cvPoint((N-1)/2,(N-1)/2);
cvCopyMakeBorder(img, img_b, offset, IPL_BORDER_REPLICATE, cvScalarAll(0));
// Make window
cvNamedWindow( name, 1 );
// Edge Detection Variables
int aperature_size = N;
double lowThresh = 20;
double highThresh = 40;
// Create trackbars
cvCreateTrackbar( "High", name, &high_switch_value, 4, switch_callback_h );
cvCreateTrackbar( "Low", name, &low_switch_value, 4, switch_callback_l );
while( 1 ) {
switch( highInt ){
case 0:
highThresh = 200;
break;
case 1:
highThresh = 400;
break;
case 2:
highThresh = 600;
break;
case 3:
highThresh = 800;
break;
case 4:
highThresh = 1000;
break;
}
switch( lowInt ){
case 0:
lowThresh = 0;
break;
case 1:
lowThresh = 100;
break;
case 2:
lowThresh = 200;
break;
case 3:
lowThresh = 400;
break;
case 4:
lowThresh = 600;
break;
}
// Edge Detection
cvCanny( img_b, out, lowThresh*N*N, highThresh*N*N, aperature_size );
cvShowImage(name, out);
if( cvWaitKey( 15 ) == 27 )
break;
}
// Release
cvReleaseImage( &img );
cvReleaseImage( &img_b );
cvReleaseImage( &out );
cvDestroyWindow( name );
return 0;
}

int angle_switch_value = 0;
int angleInt = 0;
int scale_switch_value = 0;
int scaleInt = 0;
void switch_callback_a( int position ){
angleInt = position;
}
void switch_callback_s( int position ){
scaleInt = position;
}
int _tmain(int argc, _TCHAR* argv[])
{
// Set up variables
CvPoint2D32f srcTri[3], dstTri[3];
CvMat* rot_mat = cvCreateMat(2,3,CV_32FC1);
CvMat* warp_mat = cvCreateMat(2,3,CV_32FC1);
IplImage *src, *dst;
const char* name = "Affine_Transform";
// Load image
src=cvLoadImage("MGC.jpg");
dst = cvCloneImage( src );
dst->origin = src->origin;
cvZero( dst );
cvNamedWindow( name, 1 );
// Create angle and scale
double angle = 0.0;
double scale = 1.0;
// Create trackbars
cvCreateTrackbar( "Angle", name, &angle_switch_value, 4, switch_callback_a );
cvCreateTrackbar( "Scale", name, &scale_switch_value, 4, switch_callback_s );
// Compute warp matrix
srcTri[0].x = 0;
srcTri[0].y = 0;
srcTri[1].x = src->width - 1;
srcTri[1].y = 0;
srcTri[2].x = 0;
srcTri[2].y = src->height - 1;
dstTri[0].x = src->width*0.0;
dstTri[0].y = src->height*0.25;
dstTri[1].x = src->width*0.90;
dstTri[1].y = src->height*0.15;
dstTri[2].x = src->width*0.10;
dstTri[2].y = src->height*0.75;
cvGetAffineTransform( srcTri, dstTri, warp_mat );
cvWarpAffine( src, dst, warp_mat );
cvCopy ( dst, src );
while( 1 ) {
switch( angleInt ){
case 0:
angle = 0.0;
break;
case 1:
angle = 20.0;
break;
case 2:
angle = 40.0;
break;
case 3:
angle = 60.0;
break;
case 4:
angle = 90.0;
break;
}
switch( scaleInt ){
case 0:
scale = 1.0;
break;
case 1:
scale = 0.8;
break;
case 2:
scale = 0.6;
break;
case 3:
scale = 0.4;
break;
case 4:
scale = 0.2;
break;
}
// Compute rotation matrix
CvPoint2D32f center = cvPoint2D32f( src->width/2, src->height/2 );
cv2DRotationMatrix( center, angle, scale, rot_mat );
// Do the transformation
cvWarpAffine( src, dst, rot_mat );
cvShowImage( name, dst );
if( cvWaitKey( 15 ) == 27 )
break;
}
cvReleaseImage( &dst );
cvReleaseMat( &rot_mat );
cvReleaseMat( &warp_mat );
return 0;
}

int _tmain(int argc, _TCHAR* argv[])
{
// Set up images
const char* name = "Histogram Equalization";
IplImage *img = cvLoadImage("MGC.jpg", 0);
IplImage* out = cvCreateImage( cvGetSize(img), IPL_DEPTH_8U, 1 );
// Show original
cvNamedWindow( "Original", 1) ;
cvShowImage( "Original", img );
// Perform histogram equalization
cvEqualizeHist( img, out );
// Show histogram equalized
cvNamedWindow( name, 1) ;
cvShowImage( name, out );
cvWaitKey();
cvReleaseImage( &img );
cvReleaseImage( &out );
return 0;
}
Click here to email me.
Click here to return to my Tutorials page.