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


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

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


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

示例1: QgarErrorDomain

OpenBinaryImage::OpenBinaryImage(const BinaryImage& anImg,
				 unsigned int anOpenSize)

  throw(QgarErrorDomain)

  : BinaryImage(anImg)

{
  int sqsize = (2 * anOpenSize) + 1;  // Effective mask size

  if ((sqsize > anImg.width()) || (sqsize > anImg.height()))
    {
      std::ostringstream os;
      os << "Opening size ["
	 << sqsize
	 << " X "
	 << sqsize
	 << "] too large for image ["
	 << anImg.width()
	 << " X "
	 << anImg.height()
	 << "]";
      throw QgarErrorDomain(__FILE__, __LINE__,
			    "void qgar::OpenBinaryImage::OpenBinaryImage(const qgar::BinaryImage&, unsigned int)",
			    os.str());
    }

  perform(this, anOpenSize);
}
开发者ID:rentpath,项目名称:qgar,代码行数:29,代码来源:OpenBinaryImage.cpp

示例2: QgarErrorDomain

ErodedBinaryImage::ErodedBinaryImage(BinaryImage& anImg,
				     unsigned int anEroSize)
  throw(QgarErrorDomain)

  : BinaryImage(anImg)

{
  int sqsize = (2 * anEroSize) + 1;  // Effective mask size

  if ((sqsize > anImg.width()) || (sqsize > anImg.height()))
    {
      std::ostringstream os;
      os << "Erosion size ("
	 << sqsize
	 << " X "
	 << sqsize
	 << ") too large for an image "
	 << anImg.width()
	 << " X "
	 << anImg.height();
      throw QgarErrorDomain(__FILE__, __LINE__,
			    "qgar::ErodedBinaryImage::ErodedBinaryImage(qgar::BinaryImage&, unsigned int)",
			    os.str());
    }

  perform(this, anEroSize);
}
开发者ID:rentpath,项目名称:qgar,代码行数:27,代码来源:ErodedBinaryImage.cpp

示例3: checkAlignedImage

static bool checkAlignedImage(
	ConnCompEraserExt const& eraser, BinaryImage const& nonaligned)
{
	BinaryImage const aligned(eraser.computeConnCompImageAligned());
	int const pad = aligned.width() - nonaligned.width();
	if (pad < 0) {
		return false;
	}
	
	BinaryImage test1(nonaligned);
	BinaryImage empty1(test1.size());
	empty1.fill(WHITE);
	rasterOp<RopXor<RopSrc, RopDst> >(test1, test1.rect(), aligned, QPoint(pad, 0));
	if (test1 != empty1) {
		return false;
	}
	
	if (pad > 0) {
		// Check that padding is white.
		BinaryImage test2(pad, nonaligned.height());
		BinaryImage empty2(test2.size());
		empty2.fill(WHITE);
		rasterOp<RopSrc>(test2, test2.rect(), aligned, QPoint(0, 0));
		if (test2 != empty2) {
			return false;
		}
	}
	
	return true;
}
开发者ID:4sp1r3,项目名称:scantailor,代码行数:30,代码来源:TestConnCompEraserExt.cpp

示例4: settings

void
Despeckle::despeckleInPlace(
	BinaryImage& image, Dpi const& dpi, Level const level,
	TaskStatus const& status, DebugImages* const dbg)
{
	Settings const settings(Settings::get(level, dpi));

	ConnectivityMap cmap(image, CONN8);
	if (cmap.maxLabel() == 0) {
		// Completely white image?
		return;
	}

	status.throwIfCancelled();
	
	std::vector<Component> components(cmap.maxLabel() + 1);
	std::vector<BoundingBox> bounding_boxes(cmap.maxLabel() + 1);

	int const width = image.width();
	int const height = image.height();

	uint32_t* const cmap_data = cmap.data();
	
	// Count the number of pixels and a bounding rect of each component.
	uint32_t* cmap_line = cmap_data;
	int const cmap_stride = cmap.stride();
	for (int y = 0; y < height; ++y) {
		for (int x = 0; x < width; ++x) {
			uint32_t const label = cmap_line[x];
			++components[label].num_pixels;
			bounding_boxes[label].extend(x, y);
		}
		cmap_line += cmap_stride;
	}
	
	status.throwIfCancelled();

	// Unify big components into one.
	std::vector<uint32_t> remapping_table(components.size());
	uint32_t unified_big_component = 0;
	uint32_t next_avail_component = 1;
	for (uint32_t label = 1; label <= cmap.maxLabel(); ++label) {
		if (bounding_boxes[label].width() < settings.bigObjectThreshold &&
				bounding_boxes[label].height() < settings.bigObjectThreshold) {
			components[next_avail_component] = components[label];
			remapping_table[label] = next_avail_component;
			++next_avail_component;
		} else {
			if (unified_big_component == 0) {
				unified_big_component = next_avail_component;
				++next_avail_component;
				components[unified_big_component] = components[label];
				// Set num_pixels to a large value so that canBeAttachedTo()
				// always allows attaching to any such component.
				components[unified_big_component].num_pixels = width * height;
			}
			remapping_table[label] = unified_big_component;
		}
	}
	components.resize(next_avail_component);
	std::vector<BoundingBox>().swap(bounding_boxes); // We don't need them any more.
	
	status.throwIfCancelled();

	uint32_t const max_label = next_avail_component - 1;
	
	// Remapping individual pixels.
	cmap_line = cmap_data;
	for (int y = 0; y < height; ++y) {
		for (int x = 0; x < width; ++x) {
			cmap_line[x] = remapping_table[cmap_line[x]];
		}
		cmap_line += cmap_stride;
	}
	if (dbg) {
		dbg->add(cmap.visualized(), "big_components_unified");
	}

	status.throwIfCancelled();
	
	// Build a Voronoi diagram.
	std::vector<Distance> distance_matrix;
	voronoi(cmap, distance_matrix);
	if (dbg) {
		dbg->add(cmap.visualized(), "voronoi");
	}
	
	status.throwIfCancelled();

	Distance* const distance_data = &distance_matrix[0] + width + 3;
	
	// Now build a bidirectional map of distances between neighboring
	// connected components.
	
	typedef std::map<Connection, uint32_t> Connections; // conn -> sqdist
	Connections conns;
	
	voronoiDistances(cmap, distance_matrix, conns);
	
	status.throwIfCancelled();
//.........这里部分代码省略.........
开发者ID:DevangThakkar,项目名称:scantailor,代码行数:101,代码来源:Despeckle.cpp

示例5: ccImpl

ConnectedComponents::ConnectedComponents(const BinaryImage& aBinImg)

  : componentImg_(ConnectedComponents::image_type(aBinImg.width(),
						  aBinImg.height()))

{
  // Initialize offset tables used during contour following
  // to get 4- and 8-connected neighbors in a 3X3 neighborhood.
  // See class qgar::Component for full details.

  int w = aBinImg.width();

  // 4-CONNECTIVITY
  //
  //   current (contour) direction
  //   N       E       S       W
  //   0   1   2   3   4   5   6   7   8   9  10  11  12 
  // +---+---+---+---+---+---+---+---+---+---+---+---+---+
  // | -1| * | -w| * | 1 | * | w | * | -1| * |-w | * | 1 |
  // +---+---+---+---+---+---+---+---+---+---+---+---+---+

  int tmpOff4[13] =
    {
      -1, 0, -w, 0, 1, 0, w, 0, -1, 0, -w, 0, 1
    };

  offset3X3_4_ = new int[13];
  memcpy(offset3X3_4_, tmpOff4, 13 * sizeof(int));

  // 8-CONNECTIVITY
  //
  //                      search rank
  //                      0    1    2    3    4    5  
  //                   +----+----+----+----+----+----+
  //            / N  0 | -1 | -w |-w-1|  1 |-w+1|  w |
  //            |      +----+----+----+----+----+----+
  //            | NE 1 | -w |-w-1|  1 |-w+1| w+1| w-1|
  //            |      +----+----+----+----+----+----+
  //            | E  2 | -w |  1 |-w+1|  w | w+1| -1 |
  //            |      +----+----+----+----+----+----+
  //  current   | SE 3 |  1 |-w+1|  w | w+1| w-1|-w-1|
  //  contour  <       +----+----+----+----+----+----+
  // direction  | S  4 |  1 |  w | w+1| -1 | w-1| -w |
  //            |      +----+----+----+----+----+----+
  //            | SW 5 |  w | w+1| -1 | w-1|-w-1|-w+1|
  //            |      +----+----+----+----+----+----+
  //            | W  6 |  w | -1 | w-1| -w |-w-1|  1 |
  //            |      +----+----+----+----+----+----+
  //            \ NW 7 | -1 | w-1| -w |-w-1|-w+1| w+1|
  //                   +----+----+----+----+----+----+

  int tmpOff8[48] =
    {
      -1,   -w, -w-1,    1, -w+1,    w,
      -w, -w-1,    1, -w+1,  w+1,  w-1,
      -w,    1, -w+1,    w,  w+1,   -1,
       1, -w+1,    w,  w+1,  w-1, -w-1,
       1,    w,  w+1,   -1,  w-1,   -w,
       w,  w+1,   -1,  w-1, -w-1, -w+1,
       w,   -1,  w-1,   -w, -w-1,    1,
      -1,  w-1,   -w, -w-1, -w+1,  w+1 
   };

  offset3X3_8_ = new int[48];
  memcpy(offset3X3_8_, tmpOff8, 48 * sizeof(int));

  // Initialize data in order to run the construction of components
  ConnectedComponentsImpl ccImpl(aBinImg,
				 &componentImg_,
				 componentTree_,
				 componentTab_,
				 offset3X3_4_,
				 offset3X3_8_);

   // Run the construction of connected components
  ccImpl.run();
}
开发者ID:jlerouge,项目名称:GEMpp,代码行数:77,代码来源:ConnectedComponents.cpp

示例6: 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

示例7: 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


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