当前位置: 首页>>代码示例>>C++>>正文


C++ FlexImage::Reallocate方法代码示例

本文整理汇总了C++中FlexImage::Reallocate方法的典型用法代码示例。如果您正苦于以下问题:C++ FlexImage::Reallocate方法的具体用法?C++ FlexImage::Reallocate怎么用?C++ FlexImage::Reallocate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FlexImage的用法示例。


在下文中一共展示了FlexImage::Reallocate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FlexLoadBMPColor

bool FlexLoadBMPColor(const char *file, FlexImage<Im8u,3> &img) 
{
    FILE *in;
	BITMAPFILEHDR bmfh;
	BITMAPINFOHDR bmih;	

	in=fopen(file,"rb");
	if (in == NULL)
		return(false);	
        //WARNING: Extra padding in bmfh causes erroneous reading into all but first field of structure
	fread(&bmfh,BFHSIZE,1,in);							//read BMP header
        ConvertBmfh(&bmfh);
	if (bmfh.bfType != 19778)							//check for valid BMP file
		return(false);
	fread(&bmih,BIHSIZE,1,in);							//read info header
        ConvertBmih(&bmih);
	if (bmih.biBitCount != 24) 
		return(false);									//only read 8 bit images
	img.Reallocate(bmih.biWidth, abs(bmih.biHeight));	//allocate image to size

	RGBA tmp;
	for(int i = 0; i < (int)bmih.biClrUsed; i++)		//skip color info
		fread(&tmp, sizeof(RGBA), 1, in);

	int padWidth = 3 * bmih.biWidth;
	while(padWidth%4) padWidth++;						
	int dir = 1, yv = 0;
	if (bmih.biHeight > 0)
	{	dir = -1;
		yv = img.Height() - 1;
	}
	for(int y = 0; y < img.Height(); y++ )				//read in pixel data
	{	char tmp;
		fread(&img(0,yv), 1, img.Width() * 3, in);
		yv += dir;
		for(int i = 0; i < padWidth - img.Width() * 3; i++)	//skip over pad bytes
			fread(&tmp, 1, 1, in);
	}
	fclose(in);
	return(true);
}
开发者ID:rossandon,项目名称:MobileTesting,代码行数:41,代码来源:FlexIO.cpp

示例2: FlexFilterRowVOMP

bool FlexFilterRowVOMP(FlexImage<T,1> &src, FlexImage<T,1> &dst, T2 *kernel, int kernelSize, bool allocate = true)
{
	if(kernelSize % 2 == 0)									//enforce odd length kernels
		return false;
	if(allocate)
		dst.Reallocate(src.Size());
	dst.Set((T)0);
	int n = kernelSize / 2, h = src.Height();
	#pragma omp parallel for
	for(int y = 0; y < h; y++)
	{	T *psrc = &src(n, y), *pdst = &dst(n, y);
		for(int x = n; x < src.Width() - n; x++)
		{	int k = 0;
			T2 acc = 0;
			for(int i = -n; i <= n; i++) 
				acc += (T2)(psrc[i] * kernel[k++]);
			*pdst = (T)acc;
			pdst++;
			psrc++;
		}
	}
	return true;
}
开发者ID:Ikulagin,项目名称:transmem,代码行数:23,代码来源:TrackingModelOMP.cpp

示例3: FlexFilterColumnVOMP

bool FlexFilterColumnVOMP(FlexImage<T,1> &src, FlexImage<T,1> &dst, T2 *kernel, int kernelSize, bool allocate = true)
{
	if(kernelSize % 2 == 0)									//enforce odd length kernels
		return false;
	if(allocate)
		dst.Reallocate(src.Size());
	dst.Set((T)0);
	int n = kernelSize / 2;
	int sb = src.StepBytes(), h = src.Height() - n;
	#pragma omp parallel for
	for(int y = n; y < h; y++)
	{	T *psrc = &src(0, y), *pdst = &dst(0, y);
		for(int x = 0; x < src.Width(); x++)
		{	int k = 0;
			T2 acc = 0;
			for(int i = -n; i <= n; i++) 
				acc += (T2)(*(T *)((char *)psrc + sb * i) * kernel[k++]);
			*pdst = (T)acc;
			pdst++;
			psrc++;
		}
	}
	return true;
}
开发者ID:Ikulagin,项目名称:transmem,代码行数:24,代码来源:TrackingModelOMP.cpp


注:本文中的FlexImage::Reallocate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。