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


C++ Pixel::diffIntensity方法代码示例

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


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

示例1: iter

enum ImageProcessing::ErrorCode
ImageProcessing::doFloodFill( FrameBuffer * frame,
			      FrameBuffer * outFrame,
			      Point p,
			      RawPixel seed, 
			      unsigned int threshold, 
			      ColourDefinition const * colour,
			      unsigned int subSample,
			      FloodFillState * state )
{
  Pixel pixel;
  Pixel outPixel;
  Pixel neighbour;
  unsigned int diff;
  //int ret;
  FrameBufferIterator iter( frame, 0, 0 );
  FrameBufferIterator outIter( outFrame, 0, 0 );
  Point stack[ STACK_SIZE ];
  Point c;
  enum ErrorCode err = NO_ERROR;

  // Use stackIndex = 0 as underflow check
  unsigned int stackIndex = 1;

#ifndef Q_NODEBUG
  //  std::cout << __PRETTY_FUNCTION__ << " called at (" << p.x() << ',' << p.y() << ")" << " with colour " << seed << std::endl;
#endif  

  //  state->initialize();
  
  // outFrame->fill( RawPixel(0,0,0) ); // Set to black.
  
  // If the seed is black, the flood fill will get stuck in an
  // infinite loop.  So, we skip floodfills on black seeds.
  
  if( ( seed.red == 0 ) && ( seed.green == 0 ) && ( seed.blue == 0) )
    {
      // Fudge the seed to be not all black.
      seed.blue = 1;
    }
        
  if( iter.goPosition( p.y(), p.x() ) || outIter.goPosition( p.y(), p.x() ) )
    {
      err = INVALID_SEED_POINT;
      goto exit;
    }
  
  // Push the initial point onto the stack

  stack[stackIndex++] = p;
  while( stackIndex > 1 )
    {
      if ( stackIndex >= STACK_SIZE - 4 )
	{
	  std::cerr << __PRETTY_FUNCTION__ << " ERROR: possible stack overflow " << stackIndex << std::endl;
	  err = STACK_OVERFLOW;
	  goto exit;
	}
      c = stack[--stackIndex];
#ifndef Q_NODEBUG
      //      std::cout << " processing point (" << c.x() << ',' << c.y() << ")" << std::endl;
#endif  

      if( iter.goPosition( c.y(), c.x() ) || outIter.goPosition( c.y(), c.x() ) )
	{
	  err = OUT_OF_BOUNDS;
	  goto exit;
	}
     
      iter.getPixel( & pixel, 0 );
      outIter.getPixel( & outPixel, 0 );
      
      //      if ( ! ImageProcessing::isChecked( outPixel ) )
      if ( ( outPixel.red == 0 ) && ( outPixel.green == 0 ) && ( outPixel.blue == 0 ) )
	{
	  if ( ( ( pixel.red < BRIGHT_PIXEL) && ( pixel.red > DARK_PIXEL ) ) && ( pixel.green > DARK_PIXEL ) && ( pixel.blue > DARK_PIXEL ) )
	    {
	      state->addPoint( c, pixel );
	      
	      outIter.setPixel( seed, 0 );
	      iter.setPixel( seed, 0 );
	      if ( c.x() >= subSample ) 
		{
		  iter.getPixel( &neighbour, -subSample * frame->bytesPerPixel );
		  diff = pixel.diffIntensity( neighbour );
		  if ( ( diff <= threshold ) && ( (colour == 0 ) || colour->isMatch( pixel ) ) )
		    {
		      stack[stackIndex++] = Point( c.x() - subSample, c.y() );
		    }
		}
				
	      if ( c.x() < (frame->width - 1 - subSample) ) 
		{
		  iter.getPixel( &neighbour, + subSample * frame->bytesPerPixel );
		  diff = pixel.diffIntensity( neighbour );
		  if ( ( diff <= threshold ) && ( (colour == 0 ) || colour->isMatch( pixel ) ) )
		    {
		      stack[stackIndex++] = Point( c.x() + subSample, c.y() );
		    }
		}
//.........这里部分代码省略.........
开发者ID:jackybaltes,项目名称:VisionModule,代码行数:101,代码来源:imageprocessing.cpp


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