本文整理汇总了C++中GenericImage::Intersects方法的典型用法代码示例。如果您正苦于以下问题:C++ GenericImage::Intersects方法的具体用法?C++ GenericImage::Intersects怎么用?C++ GenericImage::Intersects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericImage
的用法示例。
在下文中一共展示了GenericImage::Intersects方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Detect
template <class P> static
StarDetector::Status Detect( DPoint& pos, int& radius, float threshold, const GenericImage<P>& img )
{
img.Status().DisableInitialization();
/*
* Iteratively find the barycenter of a star.
*/
for ( int it = 0; it < 10; ++it )
{
// Central pixel in the current search box
Point p0 = pos;
// Search box
Rect r0( p0-radius, p0+radius+1 );
if ( !img.Intersects( r0 ) )
return StarDetector::OutsideImage;
// Extract the search subimage
img.SelectRectangle( r0 );
r0 = img.SelectedRectangle(); // in case the search box is clipped
Image simg( img );
// Threshold background pixels
Threshold( simg, threshold );
// Begin searching from the brightest pixel
if ( simg.LocateMaximumPixelValue( p0 ) == simg.MinimumPixelValue() )
return StarDetector::NoSignificantData;
// Coordinate and intensity accumulators.
double sx = 0, sy = 0, si = 0;
// Star bounding rectangle.
Rect r( p0, p0 );
for ( int down = 0; down < 2; ++down )
{
if ( down ? (p0.y == simg.Height()-1) : (p0.y == 0) )
continue;
for ( int y = down ? p0.y+1 : p0.y; ; )
{
double yc = y + 0.5;
int xa, xb;
/*
* Explore the left segment of this row.
*/
for ( xa = p0.x+1; xa > 0; )
{
Image::sample f = simg.Pixel( xa-1, y );
if ( f == 0 )
break;
--xa;
sx += f*(xa + 0.5);
sy += f*yc;
si += f;
}
/*
* Explore the right segment of this row.
*/
for ( xb = p0.x; xb < simg.Width()-1; )
{
Image::sample f = simg.Pixel( xb+1, y );
if ( f == 0 )
break;
++xb;
sx += f*(xb + 0.5);
sy += f*yc;
si += f;
}
/*
* Update horizontal boundaries.
*/
if ( xa < r.x0 ) // left boundary
r.x0 = xa;
if ( xb >= r.x1 ) // right boundary
r.x1 = xb+1;
/*
* Update y to explore the next row.
*/
if ( down )
{
++y;
if ( y == simg.Height() )
break;
}
else
{
if ( y == 0 )
break;
--y;
}
/*
* Decide whether we are done with this star, or if there is at
//.........这里部分代码省略.........