本文整理汇总了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() );
}
}
//.........这里部分代码省略.........