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


C++ FloatImage::row方法代码示例

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


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

示例1: stdImg

NiblackBinaryImage::NiblackBinaryImage(const GreyLevelImage& anImg,
				       const int aLowThres,
				       const int aHighThres,
				       const int aMaskSize,
				       const float aK,
				       const float aPostThres)

  : BinaryImage(anImg.width(), anImg.height())

{
  // Pointer to mean image
  FloatImage* pMeanImg = 0;

  // Compute standard deviation and mean
  StandardDeviationImage stdImg(FloatImage(anImg), pMeanImg, aMaskSize);

  // Rows to exchange data
  GreyLevelImage::pointer bRow = new GreyLevelImage::value_type [_width];
  GreyLevelImage::pointer gRow = new GreyLevelImage::value_type [_width];

  float* mRow = new float [_width];
  float* sRow = new float [_width];
  
  // Binarize
  for (int i = 0 ; i < _height ; ++i)
    {
      // Read means
      pMeanImg->row(i, mRow);
      // Read deviations
      stdImg.row(i, sRow);
      // Read original
      anImg.row(i, gRow);

      // Pointers
      float* m = mRow;
      float* s = sRow;
      GreyLevelImage::pointer g = gRow;
      GreyLevelImage::pointer b = bRow;

      // Dynamic thresholding
      for (int j = 0 ; j < _width ; ++j, ++b, ++g)
	{
	  if (*g < aLowThres)
	    {
	      *b = 1;
	    }
	  else if (*g > aHighThres)
	    {
	      *b = 0;
	    }
	  else if (*g < (GreyLevelImage::value_type) (*m++ + aK * *s++))
	    {
	      *b = 1;
	    }
	  else
	    {
	      *b = 0;
	    }
	}

      // Save line
      setRow(i, bRow);
    }

  // Post-processing
  if (aPostThres > 0)
    {
      // Copy reference image
      BinaryImage* contours = new BinaryImage(*this);

      // Extract connected components
      ConnectedComponents* compConnexes = new ConnectedComponents(*contours);

      // Prepare tables
      int labCnt = compConnexes->componentCnt();
      // Tables for the sums of the means of the gradient
      float* gsum = new float [labCnt];
      qgFill(gsum, labCnt, 0.f);
      // Tables for the numbers of points -- for the mean
      int* psum = new int [labCnt];
      qgFill(psum, labCnt, 0);

      // Table of labels
      Component::label_type* labRow = new Component::label_type[_width];
      // By construction, first and last pixels are always WHITE
      labRow[1] = 0;
      labRow[_width - 1] = 0;

      // Compute the module of Canny gradient
      CannyGradientImage* gradImg = new CannyGradientImage(anImg);
      GradientModuleImage gradModImg(*gradImg);
      delete gradImg;

      // Construct the image of the contours of the black components
      // which thus includes the interesting pixels
      ErodedBinaryImage* eroImg = new ErodedBinaryImage(*contours);
      (*contours) -= (*eroImg);
      delete eroImg;

      // Create a line of floats
//.........这里部分代码省略.........
开发者ID:jlerouge,项目名称:GEMpp,代码行数:101,代码来源:NiblackBinaryImage.cpp


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