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


C++ Image::Convolve方法代码示例

本文整理汇总了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;
}
开发者ID:grilledcheesesandwich,项目名称:Apollo,代码行数:35,代码来源:ImageFilterTest.cpp

示例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);
  }
}
开发者ID:aqchin,项目名称:imagesignal,代码行数:42,代码来源:image.cpp


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