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


C++ image::getRow方法代码示例

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


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

示例1: apply

  // On copy apply for type image!
  bool histogramRGBL::apply(const image& src,dvector& dest) const {

    if (src.empty()) {
      dest.clear();
      setStatusString("input channel empty");
      return false;
    }

    const parameters& param = getParameters();

    int theMin(0),theMax(255);

    const int lastIdx = param.cells-1;

    const float m = float(lastIdx)/(theMax-theMin);
    int y,r,g,b,l;
    int idx;
    int entries;

    vector<rgbPixel>::const_iterator it,eit;

    dest.resize(4*param.cells,0.0,false,true); // initialize with 0
    dvector theR(param.cells,0.0);
    dvector theG(param.cells,0.0);
    dvector theB(param.cells,0.0);
    dvector theL(param.cells,0.0);

    entries = 0;

    // if b too small, it's possible to calculate everything faster...

    // check if the ignore value
    if (param.considerAllData) {
      for (y=0;y<src.rows();++y) {
        const vector<rgbPixel>& vct = src.getRow(y);
        for (it=vct.begin(),eit=vct.end();it!=eit;++it) {
          r = (*it).getRed();
          g = (*it).getGreen();
          b = (*it).getBlue();
          l = (min(r,g,b)+max(r,g,b))/2;

          idx = static_cast<int>(r*m);
          theR.at(idx)++;
          idx = static_cast<int>(g*m);
          theG.at(idx)++;
          idx = static_cast<int>(b*m);
          theB.at(idx)++;
          idx = static_cast<int>(l*m);
          theL.at(idx)++;

          entries++;
        }
      }
    } else {
      for (y=0;y<src.rows();++y) {
        const vector<rgbPixel>& vct = src.getRow(y);
        for (it=vct.begin(),eit=vct.end();it!=eit;++it) {
          if ((*it) != param.ignoreValue) {
            r = (*it).getRed();
            g = (*it).getGreen();
            b = (*it).getBlue();
            l = (min(r,g,b)+max(r,g,b))/2;

            idx = static_cast<int>(r*m);
            theR.at(idx)++;
            idx = static_cast<int>(g*m);
            theG.at(idx)++;
            idx = static_cast<int>(b*m);
            theB.at(idx)++;
            idx = static_cast<int>(l*m);
            theL.at(idx)++;

            entries++;
          }
        }
      }
    }

    if (param.smooth) {
      convolution convolver;
      convolution::parameters cpar;
      cpar.boundaryType = lti::Mirror;
      cpar.setKernel(param.kernel);
      convolver.setParameters(cpar);

      matrix<double> tmp;
      tmp.useExternData(4,param.cells,&dest.at(0));

      convolver.apply(theR,tmp.getRow(0));
      convolver.apply(theG,tmp.getRow(1));
      convolver.apply(theB,tmp.getRow(2));
      convolver.apply(theL,tmp.getRow(3));

    } else {
      dest.fill(theR,0);
      dest.fill(theG,param.cells);
      dest.fill(theB,2*param.cells);
      dest.fill(theL,3*param.cells);
    }
//.........这里部分代码省略.........
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:101,代码来源:ltiHistogramRGBL.cpp


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