ImageUtils.cpp
IplImage* cropImage(const IplImage *img, const CvRect region)
{
	IplImage *imageTmp,*imageRGB;
	CvSize size;
	size.height = img->height;
	size.width = img-> width;

	if (img->depth != IPL_DEPTH_8U) {
		std::cerr << "ERROR: Unknown image depth of " << img->depth << " given in cropImage() instead of 8." << std::endl;
		exit(1);
	}

	// First create a new (color or greyscale) IPL Image and copy contents of img into it.
	imageTmp = cvCreateImage(size, IPL_DEPTH_8U, img->nChannels);
	cvCopy(img, imageTmp);

	// Create a new image of the detected region
	//printf("Cropping image at x = %d, y = %d...", faces[i].x, faces[i].y);
	//printf("Setting region of interest...");
	// Set region of interest to that surrounding the face
	cvSetImageROI(imageTmp, region);
	// Copy region of interest (i.e. face) into a new iplImage (imageRGB) and return it
	size.width = region.width;
	size.height = region.height;
	imageRGB = cvCreateImage(size, IPL_DEPTH_8U, img->nChannels);
	cvCopy(imageTmp, imageRGB);	// Copy just the region.

    cvReleaseImage( &imageTmp );
	return imageRGB;		
}
// Returns a new image that is a cropped version of the original image. 

Returns a new image that is a cropped version of the original image.
Returns a new image that is a cropped version of the original image .
IplImage* cropImage(const IplImage *img, const CvRect region)
{
	IplImage *imageTmp,*imageRGB;
	CvSize size;
	size.height = img->height;
	size.width = img-> width;
	if (img->depth != IPL_DEPTH_8U) {
		std::cerr << "ERROR: Unknown image depth of " << img->depth << " given in cropImage() instead of 8." << std::endl;
		exit(1);
	}
	imageTmp = cvCreateImage(size, IPL_DEPTH_8U, img->nChannels);
	cvCopy(img, imageTmp);
	cvSetImageROI(imageTmp, region);
	size.width = region.width;
	size.height = region.height;
	imageRGB = cvCreateImage(size, IPL_DEPTH_8U, img->nChannels);
	cvCopy(imageTmp, imageRGB);	
    cvReleaseImage( &imageTmp );
	return imageRGB;		
}
IplImage * cropImage ( const IplImage * img , const CvRect region ) { IplImage * imageTmp , * imageRGB ; CvSize size ; size . height = img -> height ; size . width = img -> width ; if ( img -> depth != IPL_DEPTH_8U ) { std :: cerr << " " << img -> depth << " " << std :: endl ; exit ( 1 ) ; } imageTmp = cvCreateImage ( size , IPL_DEPTH_8U , img -> nChannels ) ; cvCopy ( img , imageTmp ) ; cvSetImageROI ( imageTmp , region ) ; size . width = region . width ; size . height = region . height ; imageRGB = cvCreateImage ( size , IPL_DEPTH_8U , img -> nChannels ) ; cvCopy ( imageTmp , imageRGB ) ; cvReleaseImage ( & imageTmp ) ; return imageRGB ; }
Returns a new image that is a cropped version of the original image.
Returns a new image that is a cropped version of the original image .
// First create a new (color or greyscale) IPL Image and copy contents of img into it.
 // Create a new image of the detected region
 //printf("Cropping image at x = %d, y = %d...", faces[i].x, faces[i].y);
 //printf("Setting region of interest...");
 // Set region of interest to that surrounding the face
 // Copy region of interest (i.e. face) into a new iplImage (imageRGB) and return it
 // Copy just the region.
