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


C++ BinaryImage::pPixMap方法代码示例

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


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

示例1: BinaryImage

BinaryImage*
ConnectedComponents::makeBinaryImg
  (const std::vector<Component::label_type>& aLabSet)
{
  // Create the resulting image
  BinaryImage* pImgBin = new BinaryImage(componentImg_.width(),
					 componentImg_.height());

  // Pointers to pixel maps
  Component::label_type* pMapCC  = componentImg_.pPixMap();
  BinaryImage::pointer   pMapBin = pImgBin->pPixMap();

  // Current label and color
  Component::label_type currLab   = Component::LABEL_NO_;
  QGEbw                 currColor = QGE_BW_WHITE;

  // Number of pixels of both images
  int size = componentImg_.width() * componentImg_.height();


  // For each pixel of the component image

  for (int iCnt = 0 ; iCnt< size ; ++iCnt, ++pMapCC, ++pMapBin)
    {

      if (*pMapCC != currLab)
	{
	  // The new pixel belongs to a new component
	  
	  currLab = *pMapCC;

	  std::vector<Component::label_type>::const_iterator it =
	    find(aLabSet.begin(), aLabSet.end(), currLab);

	  if (   (it == aLabSet.end())
	      || ((*this)[currLab].color() == QGE_BW_WHITE))
	    {
	      // Current label does not belong to the given set
	      // or belongs to a WHITE component
	      currColor = QGE_BW_WHITE;
	    }
	  else
	    {
	      // Current label belongs to a BLACK component
	      currColor = QGE_BW_BLACK;
	    }
	}

      // Set the corresponding pixel of the resulting image
      // to current color
      *pMapBin = currColor;

    } // END for iCnt


  // Return a pointer to the resulting image
  return pImgBin;
}
开发者ID:jlerouge,项目名称:GEMpp,代码行数:58,代码来源:ConnectedComponents.cpp

示例2: sourceFile

int
main(int argc, char* argv[])
{
  QgarApp app;

  // PARAMETERS DESCRIPTION
  // ======================

  //
  app.addParameter("-in",
		   QgarArgs::REQPARAM,
		   QgarArgs::FILEIN,
		   "Source image:");

  //
  app.addParameter("-size",
		   QgarArgs::REQPARAM,
		   QgarArgs::INT,
		   "Maximum width:",
		   0,
		   "6");

  //
  app.addParameter("-outhick",
		   QgarArgs::REQPARAM,
		   QgarArgs::FILEOUTD,
		   "Image of thick lines:",
		   ".thick.pbm");

  //
  app.addParameter("-outhin",
		   QgarArgs::REQPARAM,
		   QgarArgs::FILEOUTD,
		   "Image of thin lines:",
		   ".thin.pbm");

  app.setDescription("Thick-thin separation", QgarArgs::PBM);

  // COMMAND LINE ANALYSIS
  // =====================

  app.analyzeLine(argc, argv);

  // Error while parsing parameters?
  if (app.isError())
    {
      return app._CODE_ERROR;
    }

  // Application invoked with flag '-gui'?
  if (app.isExit())
    {
      return app._CODE_GUI;
    }

  app.showProgressBar();

  // GET SOURCE IMAGE
  // ================

  cout << "Loading source image..." << endl;

  PbmFile sourceFile((char*) app.getStringOption("-in"));
  BinaryImage sourceImg = sourceFile.read();

  app.setProgressBar(20);

  // EXTRACT THICK LINES
  // ===================

  cout << "Extracting thick lines..." << endl;

  OpenBinaryImage thickImg(sourceImg, atoi(app.getStringOption("-size")) / 2);
  DilatedBinaryImage::perform(&thickImg);

  BinaryImage::value_type* pMapSource = sourceImg.pPixMap();
  BinaryImage::value_type* pMapThick  = thickImg.pPixMap();

  int size = thickImg.width() * thickImg.height();
  for (int iCnt = 0 ; iCnt < size; ++iCnt, ++pMapThick, ++pMapSource)
    {
      *pMapThick &= *pMapSource;
    }

  app.setProgressBar(50);

  // SAVE THICK LINES
  // ================

  cout << "Saving thick lines..." << endl;

  PbmFile thickFile((char*) app.getStringOption("-outhick"));
  thickFile.write(thickImg);

  app.setProgressBar(60);

  // EXTRACT THIN LINES
  // ==================

  cout << "Extracting thin lines..." << endl;
//.........这里部分代码省略.........
开发者ID:rentpath,项目名称:qgar,代码行数:101,代码来源:QAthickThinSeparation.cpp

示例3: QgarErrorInvalidArg

void
qgKanungoDegradation(BinaryImage& anImg, 
		     double alpha0, 
		     double alpha, 
		     double beta0, 
		     double beta, 
		     double eta, 
		     int structEltSize)

    throw(QgarErrorInvalidArg)

{
  // CHECK ARGUMENTS
  // ===============

  if (structEltSize < 0)
    {
      ostringstream os;
      os << "Structural element size cannot be negative ("
	 << structEltSize
	 << ')';
      throw QgarErrorInvalidArg(__FILE__, __LINE__,
				"void qgar::qgKanungoDegradation(qgar::BinaryImage&, double, double, double, double, double, int)",
				os.str());
    }

  // DISTANCE TRANSFORM
  // ==================

  Dist34Image* tmpDistImg = new Dist34Image(anImg);

  // PROBABILISTIC TRANSFORM
  // =======================

  // Random number generator initialization
  srand(time(0) + getpid() * 1000);

  // Pointers to pixel maps of initial and distance images 
  BinaryImage::pointer pMapImg  = anImg.pPixMap();
  Dist34Image::pointer pMapDist = tmpDistImg->pPixMap();

  // Image size
  int size = (anImg.width()) * (anImg.height());

  // From each pixel (top to bottom, left to right)...

  for (int iCnt = 0 ; iCnt < size ; ++iCnt, ++pMapImg, ++pMapDist)
    { 
      double proba;

      if (*pMapImg == QGE_BW_WHITE)
	{
	  // White pixel
	  proba =
	    (beta0 * exp(-beta * pow((((double) *pMapDist) / 3.), 2.)))
	    + eta;

	  // Random test
	  if (((double) rand() / (double) RAND_MAX) < proba)
	    {
	      *pMapImg = QGE_BW_BLACK;  // Swap pixel value
	    }
	}
      else 
	{
	  // Black pixel
	  proba =
	    (alpha0 * exp(-alpha * pow((((double) *pMapDist) / 3.), 2.)))
	    + eta;

	  // Random test
	  if (((double) rand() / (double) RAND_MAX) < proba)
	    {
	      *pMapImg = QGE_BW_WHITE;  // Swap pixel value
	    }
	}
    } // END for iCnt

  // DELETE TEMPORARY IMAGE
  // ======================

  delete tmpDistImg;

  // CLOSING
  // =======

  if (structEltSize != 0) 
    {
      CloseBinaryImage::perform(&anImg, structEltSize);
    }
}
开发者ID:rentpath,项目名称:qgar,代码行数:91,代码来源:KanungoBinaryImage.cpp

示例4: IntImage

// -------------------------------------------------------------------
// C O N S T R U C T O R
// -------------------------------------------------------------------
Dist34BlackCCImage::Dist34BlackCCImage(const BinaryImage& anImg)

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

{
  BinaryImage::const_pointer  pMapImg;
  Dist34BlackCCImage::pointer pMapRes;
 
  // Size of pixel maps
  int pixsize = _width * _height;
 
  // Initialization of the result image:
  // a 0 value is needed on the borders of the image

  // First line
  pMapRes = _pPixMap;
  for (int iCnt = 0 ; iCnt < _width ; ++iCnt)
    {
      *pMapRes = 0;
      ++pMapRes;
    }

  // First and last columns
  for (int iCnt = 1 ; iCnt < (_height - 1) ; ++iCnt, pMapRes += _width)
    {
      *pMapRes = 0;
      *(pMapRes + _width - 1) = 0;
    }

  // Last line
  for (int iCnt = 0 ; iCnt < _width ; ++iCnt)
    {
      *pMapRes = 0;
      ++pMapRes;
    }

  // DISTANCE TRANSFORM (DT)

  // Only the distance transform of the black pixels is computed.
  // The DT value is computed according to 4 neighbors, either black
  // or white. The direction of processing ensures that pixels are
  // always associated to a consistent DT: white pixels are always
  // associated to a DT value equal to 0 (which is neutral for this
  // operation) and black pixels result from previous computations.
  //
  // In the first step, and only in this step, we take advantage of the
  // loops to initialize white pixels.

  // STEP ONE: up to bottom and left to right

  pMapImg = anImg.pPixMap() + _width + 1;
  pMapRes = _pPixMap + _width + 1;

  for (int iCnt = 1 ; iCnt < (_height - 1) ; ++iCnt)
    {
      for (int jCnt = 1 ; jCnt < (_width - 1) ; ++jCnt, ++pMapRes, ++pMapImg)
	{
	  if (*pMapImg == QGE_BW_BLACK)
	    {
	      Dist34BlackCCImage::pointer pw = pMapRes - _width;
 
	      // BLACK pixel
	      *pMapRes = min(min(*(pMapRes - 1) + 3, *(pw - 1) + 4), 
			     min(*pw + 3, *(pw + 1) + 4));
	    }
	  else
	    {
	      // WHITE pixel
	      *pMapRes = 0;
	    }
	} // END for jCnt

      pMapRes += 2;
      pMapImg += 2;

    } // END for iCnt


  // STEP TWO: bottom to up and right to left

  pMapImg = anImg.pPixMap() + pixsize - _width - 2;
  pMapRes = _pPixMap + pixsize - _width - 2;

  for (int iCnt = _height - 2 ; iCnt > 0 ; --iCnt)
    {
      for (int jCnt = _width - 2 ; jCnt > 0 ; --jCnt, --pMapRes, -- pMapImg)
	{
	  if (*pMapImg == QGE_BW_BLACK)
	    {
	      Dist34BlackCCImage::pointer pw = pMapRes + _width;

	      *pMapRes = min(min(min(*(pMapRes + 1) + 3, *(pw + 1) + 4),
				 min(*pw + 3, *(pw - 1) + 4)),
			     *pMapRes);
	    }
	} // END for jCnt

//.........这里部分代码省略.........
开发者ID:rentpath,项目名称:qgar,代码行数:101,代码来源:Dist34BlackCCImage.cpp

示例5: if


//.........这里部分代码省略.........
  // (1.2) Delete useless Gradient image
  // =====
  delete gradImg;

  /*
   * (1.3) The activity of a given pixel is the sum of the Gradient
   * ===== modules of the pixels around:
   *             
   *  +--------------> X              i = x+1  j = y+1  
   *  | g g g g g g g                  __       __
   *  | g g G G G g g                  \        \  
   *  | g g G A G g g        A(x,y) =  /        /   gradModImg(i,j)
   *  | g g G G G g g                  --       --
   *  | g g g g g g g                 i = x-1  j = y-1
   *  v
   *  Y
   *
   * => Convolve the Gradient module image
   *    using a 3x3 mask with all coefficients set to 1
   *
   * Class ConvolImage should be used to perform the convolution:
   *
   * FConvolImage* actImg = new FConvolImage(*gradModImg, FMask2d(3,3,1.0));
   *
   * but multiplications by the mask coefficients would consume
   * a substantial amount of time.
   */

  GenImage<LaplacianOfGaussianImage::value_type>*
    actImg = new GenImage<LaplacianOfGaussianImage::value_type>(imgWidth, imgHeight);

  // pActImg     : first pixel to be processed in the activity image
  // pGradModImg : corresponding pixel in the Gradient image
  pActImg     = actImg->pPixMap()     + imgWidthPlus1;
  pGradModImg = gradModImg->pPixMap() + imgWidthPlus1;

  for (int rowIdx = 0 ; rowIdx < imgHeightMinus2 ; ++rowIdx)
    {
      for (int colIdx = 0 ; colIdx < imgWidthMinus2 ; ++colIdx)
	{
	  *pActImg =   *(pGradModImg - imgWidthMinus1) // nw  |  |  |  |
	             + *(pGradModImg - imgWidth)       // n  -+--+--+--+-
	             + *(pGradModImg - imgWidthPlus1)  // ne  |nw| n|ne|
	             + *(pGradModImg - 1)              // w  -+--+--+--+-
	             + *pGradModImg                    // A   | w| A| e|
	             + *(pGradModImg + 1)              // e  -+--+--+--+-
	             + *(pGradModImg + imgWidthMinus1) // sw  |sw| s|se|
	             + *(pGradModImg + imgWidth)       // s  -+--+--+--+-
	             + *(pGradModImg + imgWidthPlus1); // se  |  |  |  |
	  ++pActImg;
	  ++pGradModImg;
	}
      pActImg     += 2;
      pGradModImg += 2;
    }


  // ===================================================================
  // (2) IMAGE OF LABELS AND CORRESPONDING BINARY IMAGE
  // ===================================================================

  // (2.1) Each pixel is associated with a label among {-,0,+}, stored
  // ===== at same coordinates in the current image (this), such as:
  //
  //          | 0  if  A(x,y) <  anActThrs
  // L(x,y) = | +  if  A(x,y) >= anActThrs  and  Laplacian(x,y) >= 0
开发者ID:jlerouge,项目名称:GEMpp,代码行数:67,代码来源:TTBinaryImage.cpp


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