本文整理汇总了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;
}