Exemplo n.º 1
0
   void WriteToImage( vector<tStreak> const& sl, tImgPlanar& p, int color, int border ) {
      assert( p.is_mono8() );
      auto iobj = sl.begin();
      auto iend = sl.end();

      if( border == -1 ) {
         while( iobj != iend ) {
            auto y = iobj->y();
            fill( p[0][ y ].begin() + iobj->x(), p[0][ y ].begin() + iobj->end(), color );
            ++iobj;
         }

         return;
      }

      while( iobj != iend ) {
         if( iobj->length() > 2 ) {

            int y = iobj->y();
            int x = iobj->x();
            fill( p[0][ y ].begin() + x, p[0][ y ].begin() + x + iobj->length(), color );
         }

         p.pixel( uint32_xy( iobj->x(), iobj->y() ), border );
         p.pixel( uint32_xy( iobj->last(), iobj->y() ), border );
         ++iobj;
      }

   }
Exemplo n.º 2
0
double_xyz rimginterface::MaximumInArea( tImgPlanar const& im, tAoi area ) {
    assert( im.is_mono8() );
    int iy = area.sy();
    const int x =  area.px();
    const int y =  area.py();
    int max = 0;

    while( iy-- ) {
        int ix = area.sx();

        while( ix-- ) {

            int val = im[0][ y + iy ][ x + ix];

            if( val > max ) {
                max = val;
            }
        }

    }

    vector<int32_xy> newxy( area.sx()*area.sy() + 1 );
    // tixy *xy = newxy();

    uint32_t maxcount = 0;
    iy = area.sy();

    while( iy-- ) {
        int ix = area.sx();

        while( ix-- ) {
            int val = im.pixel( uint32_xy( x + ix, y + iy ) );

            if( val == max ) {
                newxy[ maxcount ].setx( x + ix );
                newxy[ maxcount ].sety( y + iy );
                maxcount++;
            }
        }
    }

    if( maxcount == 0 ) {
        assert( false );
    }


    double dx = 0.0;
    double dy = 0.0;
    uint32_t count = maxcount;

    while( count ) {
        count--;
        dx += static_cast<double>(newxy[ count ].x());
        dy += static_cast<double>(newxy[ count ].y());
    }

    dx /= static_cast<double>(maxcount);
    dy /= static_cast<double>(maxcount);
    return double_xyz( dx, dy, max );
}
Exemplo n.º 3
0
 inline uint32_xy to( int32_xy xy ) {
    return uint32_xy( xy.x(), xy.y() );
 }
Exemplo n.º 4
0
 tAoi::tAoi( int32_t ix, int32_t iy, uint32_t sx_, uint32_t sy_ ):_pos(), _size( )  {
    _pos =  int32_xy( ix, iy );
    _size =   uint32_xy( sx_, sy_ );
 }
Exemplo n.º 5
0
 uint32_xy tBlob::size()const {
    return uint32_xy( sx(), sy() );
 }