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


C++ GenericImage::Intersects方法代码示例

本文整理汇总了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
//.........这里部分代码省略.........
开发者ID:GeorgViehoever,项目名称:PCL,代码行数:101,代码来源:StarDetector.cpp


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