Ask Your Question
0

Histogram Template Matching

asked 2012-12-22 10:15:33 -0600

shelly gravatar image

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;

}

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2012-12-22 12:14:59 -0600

rics gravatar image

If your comment is correct then at least you have changed the image and the template in the cvMatchTemplate call.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-12-22 10:15:33 -0600

Seen: 721 times

Last updated: Dec 22 '12