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


C++ Image32::GaussianSample方法代码示例

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


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

示例1: sqrt

int Image32::RotateGaussian(const float& angle,Image32& outputImage) const
{
	int height = this->height();
	int width = this->width();

	double rad = -1.0 * angle * (M_PI/180.0);

	double midHeight = (height/2.0);
	double midWidth = (width/2.0);

	double diagonal = sqrt(midHeight*midHeight + midWidth*midWidth);

	int offset = ceil(diagonal - min(midWidth, midHeight));

	Image32 interImage;
	interImage.setSize(width+(2*offset), height+(2*offset));

	outputImage.setSize(width+(2*offset), height+(2*offset));

	float variance = 2;
	float radius = 2;

	for(int y=0; y < height; ++y){
		for(int x=0; x < width; ++x){
			int xOffset = x + offset;
			int yOffset = y + offset;

			interImage.pixel(xOffset, yOffset).r = this->pixel(x,y).r;
			interImage.pixel(xOffset, yOffset).g = this->pixel(x,y).g;
			interImage.pixel(xOffset, yOffset).b = this->pixel(x,y).b;
		}
	}

	for(int y=-1*offset; y < height + offset; ++y){
		for(int x=-1*offset; x < width + offset; ++x){
			int xOffset = x + offset;
			int yOffset = y + offset;

			float u = cos(rad)*(x - midWidth) - sin(rad)*(y - midHeight) + offset + midWidth;
			float v = sin(rad)*(x - midWidth) + cos(rad)*(y - midHeight) + offset + midHeight;


			Pixel32 pix = interImage.GaussianSample(u,v, variance, radius);


			outputImage.pixel(xOffset,yOffset).r = pix.r;
			outputImage.pixel(xOffset,yOffset).g = pix.g;
			outputImage.pixel(xOffset,yOffset).b = pix.b;
			outputImage.pixel(xOffset,yOffset).a = pix.a;

			// useful for debugging
			// outputImage.pixel(xOffset,yOffset).r = interImage.pixel(xOffset, yOffset).r;
			// outputImage.pixel(xOffset,yOffset).g = interImage.pixel(xOffset, yOffset).g;
			// outputImage.pixel(xOffset,yOffset).b = interImage.pixel(xOffset, yOffset).b;
		}
	}

	return 1;
}
开发者ID:jnayak1,项目名称:CS-4810,代码行数:59,代码来源:image.todo.cpp


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