本文整理汇总了C++中Image::Convolve方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::Convolve方法的具体用法?C++ Image::Convolve怎么用?C++ Image::Convolve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::Convolve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
bool ImageFilterTest::Execute() {
m_timer.Start();
FilterKernel kernel2D, kernel1D;
FilterKernel::CreateTriangleFilter2D(&kernel2D, 11);
FilterKernel::CreateTriangleFilter1D(&kernel1D, 11);
Image* image = ApolloTestFramework::LoadImage("Lighthouse.png", ApolloTestFramework::DATA_IMAGE);
VALIDATE_NOT_NULL(image);
m_allocator.Add(image);
Image* blurred2D = image->Convolve(&kernel2D, Apollo::Image::IMAGE_FILTER_EDGE_IGNORE);
VALIDATE_NOT_NULL(blurred2D);
m_allocator.Add(blurred2D);
Image* blurred1D = image->ConvolveSeperated(&kernel1D, Apollo::Image::IMAGE_FILTER_EDGE_IGNORE);
VALIDATE_NOT_NULL(blurred1D);
m_allocator.Add(blurred1D);
Image* mipMapped = image->GenerateMipMap();
VALIDATE_NOT_NULL(mipMapped);
m_allocator.Add(mipMapped);
image->ToGrayscale(image);
m_timer.Stop();
bool passed = true;
passed &= ApolloTestFramework::Instance()->ProcessResult(this, blurred2D, "LightHouseBlurred2D.png");
passed &= ApolloTestFramework::Instance()->ProcessResult(this, blurred1D, "LightHouseBlurred1D.png");
passed &= ApolloTestFramework::Instance()->ProcessResult(this, mipMapped, "LightHouseMipmapped.png");
passed &= ApolloTestFramework::Instance()->ProcessResult(this, image, "LightHouseGrayscale.png");
return passed;
}
示例2: EdgeDetect
void Image::EdgeDetect(int threshold)
{
int* filtH = new int[9];
int* filtV = new int[9];
filtH[0] = -1;
filtH[1] = 0;
filtH[2] = 1;
filtH[3] = -2;
filtH[4] = 0;
filtH[5] = 2;
filtH[6] = -1;
filtH[7] = 0;
filtH[8] = 1;
filtV[0] = 1;
filtV[1] = 2;
filtV[2] = 1;
filtV[3] = 0;
filtV[4] = 0;
filtV[5] = 0;
filtV[6] = -1;
filtV[7] = -2;
filtV[8] = -1;
Image gx = Image(*this);
Image gy = Image(*this);
int n = 3;
int norm = 1;
gx.Convolve(filtH, n, norm, true);
gy.Convolve(filtV, n, norm, true);
for (int i = 0; i < num_pixels; i++) {
int gxmag = gx.pixels[i].Luminance();
int gymag = gy.pixels[i].Luminance();
double gmag = sqrt((double) gxmag*gxmag + gymag*gymag);
if (gmag > threshold)
gmag = 255;
else
gmag = 0;
pixels[i].SetClamp(gmag, gmag, gmag);
}
}