Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Histogram Template Matching

Hi OpenCV. I tryed to compare between 2 pictures (Image and Template) and find the area most similiar to the template in the larger image, when I run the program it shows 6 small windows without image inside them. I worked with this webside: http://dasl.mem.drexel.edu/~noahKuntz/openCVTut6.html (look at Template Matching) Please Help Me!

My system:

int main(int argc, TCHAR* argv[])

{

IplImage *f,* f1,*ex[6]; 

int i;

f1 = cvLoadImage( "DSC08221.jpg" );//Image
f= cvLoadImage( "DSC08223.jpg" );//Template



int iwidth = f->width - f1->width + 1;
int iheight = f->height - f1->height + 1;
for(i=0;i<6;++i)
{
    ex[i]= cvCreateImage( cvSize( iwidth, iheight ), 32, 1 );
}

//compare
for(i=0;i<6;++i)
{
    cvMatchTemplate(f, f1, ex[i], i );
    cvNormalize( ex[i], ex[i], 1, 0, CV_MINMAX );

}

cvNamedWindow( "flower");
cvShowImage("flower", f);
cvNamedWindow( "flowers");
cvShowImage("flowers",f1);
cvNamedWindow( "take0t");
cvShowImage("take0t",ex[0]);
cvNamedWindow( "take0i");
cvShowImage("take0i",ex[1]);
cvNamedWindow( "take1t");
cvShowImage("take1t",ex[2]);
cvNamedWindow( "take1i");
cvShowImage("take1i",ex[3]);
cvNamedWindow( "take2t");
cvShowImage("take2t",ex[4]);
cvNamedWindow( "take2i");
cvShowImage("take2i",ex[5]);

cvWaitKey(0);

cvReleaseImage( &f );
cvDestroyWindow( "flower" );
cvReleaseImage( &f1 );
cvDestroyWindow( "flowers" );
cvReleaseImage( &ex[0] );
cvDestroyWindow( "take0t" );
cvReleaseImage( &ex[1] );
cvDestroyWindow( "take0i" );
cvReleaseImage( &ex[2] );
cvDestroyWindow( "take1t" );
cvReleaseImage( &ex[3] );
cvDestroyWindow( "take1i" );
cvReleaseImage( &ex[4] );
cvDestroyWindow( "take2t" );
cvReleaseImage( &ex[5] );
cvDestroyWindow( "take2i" );

return 0;

}