⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 warpipl.cpp

📁 3D reconstruction, medical image processing from colons, using intel image processing for based clas
💻 CPP
📖 第 1 页 / 共 3 页
字号:
BOOL FloatABGRImage2IntBGRAImage(char *in_image, char *out_image, int width, int height){	IplImage *srcImage = iplCreateImageHeader(		4, // number of channels		0, // no alpha channel		IPL_DEPTH_32F, // data of float point type		"RGBA", // color model		"BGRA", // color order		IPL_DATA_ORDER_PIXEL, // channel arrangement		IPL_ORIGIN_TL, // top left orientation		IPL_ALIGN_QWORD, // 8 bytes align		width, // image width		height, // image height		NULL,NULL,NULL,NULL);	if( NULL == srcImage ) return FALSE;	srcImage->imageData = in_image;	IplImage *dstImage = iplCreateImageHeader(		4, // number of channels		0, // no alpha channel		IPL_DEPTH_8U, // data of byte type		"RGBA", // color model		"BGRA", // color order		IPL_DATA_ORDER_PIXEL, // channel arrangement		IPL_ORIGIN_TL, // top left orientation		IPL_ALIGN_QWORD, // 8 bytes align		width, // image width		height, // image height		NULL,NULL,NULL,NULL);	if( NULL == dstImage ) return FALSE;	dstImage->imageData = (char*)out_image;	iplScaleFP (srcImage, dstImage, 0.0f, 1.0f); // min, max value	iplDeallocate( srcImage, IPL_IMAGE_HEADER );	iplDeallocate( dstImage, IPL_IMAGE_HEADER );			int iLoopCount = width * height;	unsigned int *piImage = (unsigned int*)out_image;	for(int i=0; i<iLoopCount; i++) {		piImage[i] = (piImage[i] >> 8) | (piImage[i] << 24);	}	return TRUE;}BOOL WarpFloatImage2RGBAImage(BYTE *in_image, int in_width, int in_height, 		  unsigned char *out_image, int out_width,		  int out_height, const double warp_matrix[2][3]){	IplImage *srcImage = iplCreateImageHeader(		4, // number of channels		0, // no alpha channel		IPL_DEPTH_32F, // data of float point type		"RGBA", // color model		"BGRA", // color order		IPL_DATA_ORDER_PIXEL, // channel arrangement		IPL_ORIGIN_TL, // top left orientation		IPL_ALIGN_QWORD, // 8 bytes align		in_width, // image width		in_height, // image height		NULL,NULL,NULL,NULL);	if( NULL == srcImage ) return FALSE;	srcImage->imageData = (char*)in_image;	IplImage *dstImage = iplCreateImageHeader(		4, // number of channels		0, // no alpha channel		IPL_DEPTH_8U, // data of byte type		"RGBA", // color model		"BGRA", // color order		IPL_DATA_ORDER_PIXEL, // channel arrangement		IPL_ORIGIN_TL, // top left orientation		IPL_ALIGN_QWORD, // 8 bytes align		out_width, // image width		out_height, // image height		NULL,NULL,NULL,NULL);	if( NULL == dstImage ) return FALSE;	dstImage->imageData = (char*)out_image;	IplImage *tempImage = iplCreateImageHeader(		4, // number of channels		0, // no alpha channel		IPL_DEPTH_8U, // data of float point type		"RGBA", // color model		"BGRA", // color order		IPL_DATA_ORDER_PIXEL, // channel arrangement		IPL_ORIGIN_TL, // top left orientation		IPL_ALIGN_QWORD, // 8 bytes align		in_width, // image width		in_height, // image height		NULL,NULL,NULL,NULL);	if( NULL == tempImage ) return FALSE;	iplAllocateImage(tempImage , 0, 0);	iplScaleFP (srcImage, tempImage, 0.0f, 1.0f); // min, max value	int iLoopCount = in_width * in_height;	unsigned int *piImage = (unsigned int*)tempImage->imageData;	for(int i=0; i<iLoopCount; i++) {		piImage[i] = (piImage[i] >> 8) | (piImage[i] << 24);	}	iplWarpAffine(tempImage, dstImage, warp_matrix, IPL_INTER_LINEAR|IPL_SMOOTH_EDGE);	iplDeallocate( srcImage, IPL_IMAGE_HEADER );	iplDeallocate(tempImage, IPL_IMAGE_ALL);	iplDeallocate( dstImage, IPL_IMAGE_HEADER );	return TRUE;}BOOL WarpFloatImage2RGBAImagePerspective(BYTE *in_image, int in_width, int in_height, 		  unsigned char *out_image, int out_width, int out_height,		  const double warp_matrix[3][3]){	IplImage *srcImage = iplCreateImageHeader(		4, // number of channels		0, // no alpha channel		IPL_DEPTH_32F, // data of float point type		"RGBA", // color model		"BGRA", // color order		IPL_DATA_ORDER_PIXEL, // channel arrangement		IPL_ORIGIN_TL, // top left orientation		IPL_ALIGN_QWORD, // 8 bytes align		in_width, // image width		in_height, // image height		NULL,NULL,NULL,NULL);	if( NULL == srcImage ) return FALSE;	srcImage->imageData = (char*)in_image;	IplImage *dstImage = iplCreateImageHeader(		4, // number of channels		0, // no alpha channel		IPL_DEPTH_8U, // data of byte type		"RGBA", // color model		"BGRA", // color order		IPL_DATA_ORDER_PIXEL, // channel arrangement		IPL_ORIGIN_TL, // top left orientation		IPL_ALIGN_QWORD, // 8 bytes align		out_width, // image width		out_height, // image height		NULL,NULL,NULL,NULL);	if( NULL == dstImage ) return FALSE;	dstImage->imageData = (char*)out_image;	IplImage *tempImage = iplCreateImageHeader(		4, // number of channels		0, // no alpha channel		IPL_DEPTH_8U, // data of float point type		"RGBA", // color model		"BGRA", // color order		IPL_DATA_ORDER_PIXEL, // channel arrangement		IPL_ORIGIN_TL, // top left orientation		IPL_ALIGN_QWORD, // 8 bytes align		in_width, // image width		in_height, // image height		NULL,NULL,NULL,NULL);	if( NULL == tempImage ) return FALSE;	iplAllocateImage(tempImage , 0, 0);	iplScaleFP (srcImage, tempImage, 0.0f, 1.0f); // min, max value	int iLoopCount = in_width * in_height;	unsigned int *piImage = (unsigned int*)tempImage->imageData;	for(int i=0; i<iLoopCount; i++) {		piImage[i] = (piImage[i] >> 8) | (piImage[i] << 24);	}	int warpFlag = 0;	iplWarpPerspective(tempImage, dstImage, warp_matrix, warpFlag, IPL_INTER_LINEAR | IPL_SMOOTH_EDGE);	iplDeallocate( srcImage, IPL_IMAGE_HEADER );	iplDeallocate(tempImage, IPL_IMAGE_ALL);	iplDeallocate( dstImage, IPL_IMAGE_HEADER );	return TRUE;}void Warp8U(char *in_image, int in_width, int in_height, 				  char *out_image, int out_width,				  int out_height, const double warp_matrix[2][3]){	IplImage *srcImage = iplCreateImageHeader(		4, // number of channels		4, // no alpha channel		IPL_DEPTH_8U, // data of byte type		"RGBA", // color model		"BGRA", // color order		IPL_DATA_ORDER_PIXEL, // channel arrangement		IPL_ORIGIN_TL, // top left orientation		IPL_ALIGN_QWORD, // 8 bytes align		in_width, // image width		in_height, // image height		NULL, // no ROI		NULL, // no mask ROI		NULL, // no image ID		NULL); // not tiled	if( NULL == srcImage ) return;	srcImage->imageData = in_image;	IplImage *dstImage = iplCreateImageHeader(		4, // number of channels		4, // no alpha channel		IPL_DEPTH_8U, // data of byte type		"RGBA", // color model		"BGRA", // color order		IPL_DATA_ORDER_PIXEL, // channel arrangement		IPL_ORIGIN_TL, // top left orientation		IPL_ALIGN_QWORD, // 8 bytes align		out_width, // image width		out_height, // image height		NULL, // no ROI		NULL, // no mask ROI		NULL, // no image ID		NULL); // not tiled	if( NULL == dstImage ) return;	dstImage->imageData = out_image;	iplWarpAffine(srcImage, dstImage, warp_matrix, IPL_INTER_LINEAR|IPL_SMOOTH_EDGE);	iplDeallocate( srcImage, IPL_IMAGE_HEADER );	iplDeallocate( dstImage, IPL_IMAGE_HEADER );	return;}void WarpGray(BYTE *in_image, int in_width, int in_height, 				  BYTE *out_image, int out_width,				  int out_height, const double warp_matrix[2][3], int bpp){	int channel;	int alpha;	int type;	char *model;	char *order;	switch(bpp) {	case 1:		channel = 1;		alpha = 0;		type = IPL_DEPTH_8U;		model = "Gray";		order = "Gray";		break;	case 2:		channel = 1;		alpha = 0;		type = IPL_DEPTH_16U;		model = "Gray";		order = "Gray";		break;	}	IplImage *srcImage = iplCreateImageHeader(		channel, // number of channels		alpha, // no alpha channel		type, // data of byte type		model, // color model		order, // color order		IPL_DATA_ORDER_PIXEL, // channel arrangement		IPL_ORIGIN_TL, // top left orientation		IPL_ALIGN_DWORD, // 4 bytes align		in_width, // image width		in_height, // image height		NULL, // no ROI		NULL, // no mask ROI		NULL, // no image ID		NULL); // not tiled	if( NULL == srcImage ) return;	srcImage->imageData = (char*)in_image;	IplImage *dstImage = iplCreateImageHeader(		channel, // number of channels		alpha, // no alpha channel		type, // data of byte type		model, // color model		order, // color order		IPL_DATA_ORDER_PIXEL, // channel arrangement		IPL_ORIGIN_TL, // top left orientation		IPL_ALIGN_DWORD, // 4 bytes align		out_width, // image width		out_height, // image height		NULL, // no ROI		NULL, // no mask ROI		NULL, // no image ID		NULL); // not tiled	if( NULL == dstImage ) return;	dstImage->imageData = (char*)out_image;	iplWarpAffine(srcImage, dstImage, warp_matrix, IPL_INTER_LINEAR|IPL_SMOOTH_EDGE);	iplDeallocate( srcImage, IPL_IMAGE_HEADER );	iplDeallocate( dstImage, IPL_IMAGE_HEADER );	return;}BOOL Zoom2Xfloat(BYTE *in_image, int in_width, int in_height,				  BYTE *out_image, int out_width, int out_height){	IplImage *srcImage;	IplImage *dstImage;	if(in_width*2 != out_width)		return FALSE;	if(in_height*2 != out_height)		return FALSE;	srcImage = iplCreateImageHeader(		4, // number of channels		0, // no alpha channel		IPL_DEPTH_32F, // data of float point type		"RGBA", // color model		"BGRA", // color order		IPL_DATA_ORDER_PIXEL, // channel arrangement		IPL_ORIGIN_TL, // top left orientation		IPL_ALIGN_QWORD, // 8 bytes align		in_width, // image width		in_height, // image height		NULL, NULL, NULL, NULL); // not tiled	dstImage = iplCreateImageHeader(		4, // number of channels		0, // no alpha channel		IPL_DEPTH_32F, // data of float point type		"RGBA", // color model		"BGRA", // color order		IPL_DATA_ORDER_PIXEL, // channel arrangement		IPL_ORIGIN_TL, // top left orientation		IPL_ALIGN_QWORD, // 8 bytes align		in_width, // image width		in_height, // image height		NULL, NULL, NULL, NULL); // not tiled		if( NULL == srcImage ) {		return FALSE;	}	srcImage->imageData = (char*)in_image;	if( NULL == dstImage ) {		iplDeallocate( srcImage, IPL_IMAGE_HEADER );		return FALSE;	}	dstImage->imageData = (char*)out_image;	iplResize(srcImage, dstImage, out_width, in_width, out_height, in_height, IPL_INTER_LINEAR);	iplDeallocate( srcImage, IPL_IMAGE_HEADER );	iplDeallocate( dstImage, IPL_IMAGE_HEADER );	return TRUE;}void MakeThumb(BYTE *in_image, int in_width, int in_height, BYTE *out_image, int out_width, int out_height, 			   int out_xoffset, int out_yoffset, int width, int height, int color){	IplImage *srcImage;	IplImage *dstImage;	IplROI	DstROI;	iplSetROI(&DstROI, 0, out_xoffset, out_height-height-out_yoffset, width, height);	if(color == 4) {//		ASSERT(in_width % 2 == 0 && out_width % 2 == 0);		srcImage = iplCreateImageHeader(			4, // number of channels			4, // no alpha channel			IPL_DEPTH_8U, // data of byte type			"RGBA", // color model			"BGRA", // color order			IPL_DATA_ORDER_PIXEL, // channel arrangement			IPL_ORIGIN_TL, // top left orientation			IPL_ALIGN_DWORD, // 8 bytes align			in_width, // image width			in_height, // image height			NULL, NULL, NULL, NULL); // not tiled		dstImage = iplCreateImageHeader(			4, // number of channels			4, // no alpha channel			IPL_DEPTH_8U, // data of byte type			"RGBA", // color model			"BGRA", // color order			IPL_DATA_ORDER_PIXEL, // channel arrangement			IPL_ORIGIN_TL, // top left orientation			IPL_ALIGN_DWORD, // 8 bytes align			out_width, // image width			out_height, // image height			NULL, NULL, NULL, NULL); // not tiled	}	if( NULL == srcImage ) return;	srcImage->imageData = (char*)in_image;	if( NULL == dstImage ) return;	dstImage->imageData = (char*)out_image;	iplSet(dstImage, 0);//	srcImage->roi = &SrcROI;	dstImage->roi = &DstROI;	iplDecimate(srcImage, dstImage, width, in_width, height, in_height, IPL_INTER_LINEAR);	iplDeallocate( srcImage, IPL_IMAGE_HEADER );	iplDeallocate( dstImage, IPL_IMAGE_HEADER );}void CropnZoom(BYTE *in_image, int in_width, int in_height, BYTE *out_image, int out_width, int out_height,			   int in_xoffset, int in_yoffset, int swidth, int sheight,			   int out_xoffset, int out_yoffset, int twidth, int theight, int color){	IplImage *srcImage;	IplImage *dstImage;	IplROI	SrcROI, DstROI;	iplSetROI(&SrcROI, 0, in_xoffset, in_yoffset, swidth, sheight);	iplSetROI(&DstROI, 0, out_xoffset, out_yoffset, twidth, theight);	if(color == 4) {//		ASSERT(in_width % 2 == 0 && out_width % 2 == 0);		srcImage = iplCreateImageHeader(			4, // number of channels			4, // no alpha channel			IPL_DEPTH_8U, // data of byte type			"RGBA", // color model			"BGRA", // color order			IPL_DATA_ORDER_PIXEL, // channel arrangement			IPL_ORIGIN_TL, // top left orientation			IPL_ALIGN_DWORD, // 8 bytes align			in_width, // image width			in_height, // image height			NULL, NULL, NULL, NULL); // not tiled		dstImage = iplCreateImageHeader(			4, // number of channels			4, // no alpha channel			IPL_DEPTH_8U, // data of byte type			"RGBA", // color model			"BGRA", // color order			IPL_DATA_ORDER_PIXEL, // channel arrangement			IPL_ORIGIN_TL, // top left orientation			IPL_ALIGN_DWORD, // 8 bytes align			out_width, // image width			out_height, // image height			NULL, NULL, NULL, NULL); // not tiled	} else if(color == 2) {		ASSERT(in_width % 2 == 0 && out_width % 2 == 0);		srcImage = iplCreateImageHeader(			1, // number of channels			0, // no alpha channel			IPL_DEPTH_16U, // data of byte type			"Gray", // color model			"Gray", // color order			IPL_DATA_ORDER_PIXEL, // channel arrangement			IPL_ORIGIN_TL, // top left orientation			IPL_ALIGN_DWORD, // 4 bytes align			in_width, // image width			in_height, // image height			NULL, NULL, NULL, NULL); // not tiled		dstImage = iplCreateImageHeader(			1, // number of channels			0, // no alpha channel			IPL_DEPTH_16U, // data of byte type			"Gray", // color model			"Gray", // color order			IPL_DATA_ORDER_PIXEL, // channel arrangement			IPL_ORIGIN_TL, // top left orientation

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -