Beispiel #1
0
void flip( const Mat& src, Mat& dst, int flip_mode )
{
    static FlipHorizFunc tab[] =
    {
        0,
        flipHoriz_<uchar>, // 1
        flipHoriz_<ushort>, // 2
        flipHoriz_<Vec<uchar,3> >, // 3
        flipHoriz_<int>, // 4
        0,
        flipHoriz_<Vec<ushort,3> >, // 6
        0,
        flipHoriz_<int64>, // 8
        0, 0, 0,
        flipHoriz_<Vec<int,3> >, // 12
        0, 0, 0,
        flipHoriz_<Vec<int64,2> >, // 16
        0, 0, 0, 0, 0, 0, 0,
        flipHoriz_<Vec<int64,3> >, // 24
        0, 0, 0, 0, 0, 0, 0,
        flipHoriz_<Vec<int64,4> > // 32
    };
    
    dst.create( src.size(), src.type() );

    if( flip_mode == 0 )
        flipVert( src, dst );
    else
    {
        int esz = (int)src.elemSize();
        CV_Assert( esz <= 32 );
        FlipHorizFunc func = tab[esz];
        CV_Assert( func != 0 );

        if( flip_mode > 0 )
            func( src, dst, false );
        else if( src.data != dst.data )
            func( src, dst, true );
        else
        {
            func( dst, dst, false );
            flipVert( dst, dst );
        }
    }
}
void flip( InputArray _src, OutputArray _dst, int flip_mode )
{
    Mat src = _src.getMat();
    
    CV_Assert( src.dims <= 2 );
    _dst.create( src.size(), src.type() );
    Mat dst = _dst.getMat();
    size_t esz = src.elemSize();

    if( flip_mode <= 0 )
        flipVert( src.data, src.step, dst.data, dst.step, src.size(), esz );
    else
        flipHoriz( src.data, src.step, dst.data, dst.step, src.size(), esz );
    
    if( flip_mode < 0 )
        flipHoriz( dst.data, dst.step, dst.data, dst.step, dst.size(), esz );
}
Beispiel #3
0
void generate(void)
{
  int fn, i, blockChoice;
        
  for(i = 0; i < 10; i++) {
                
    fn = rand() % 10;
    blockChoice = rand() % 3;
                
    switch(fn)
      {
      case 0: 
        switch(blockChoice)
          {
          case 0:
            swapLittleRow(rand() % 3, rand() % 3);
            break;
                                        
          case 1:
            swapLittleRow((rand() % 3) + 3, (rand() % 3) + 3);
            break;
                                        
          case 2: 
            swapLittleRow((rand() % 3) + 6, (rand() % 3) + 6);
            break;
                                        
          }
        break;
      case 1: 
        swapBigRow((rand() % 3), (rand() % 3));
        break;
                        
      case 2: 
        switch(blockChoice)
          {
          case 0:
            swapLittleCol((rand() % 3), (rand() % 3));
            break;
                                        
          case 1:
            swapLittleCol((rand() % 3) + 3, (rand() % 3) + 3);
            break;
                                        
          case 2: 
            swapLittleCol((rand() % 3) + 6, (rand() % 3) + 6);
            break;
          }
        break;
      case 3: 
        swapBigCol((rand() % 3), (rand() % 3));
        break;
                        
      case 4: 
        flipVert();                     
        break;
                        
      case 5: 
        flipHorz();
        break;
                        
      case 6: 
        flipDiag();
        break;
                        
      case 7: 
        rotate90cw();
        break;
                        
      case 8: 
        rotate90ccw();
        break;
                        
      case 9: 
        replace((rand() % 9) + 1, (rand()  % 9)+ 1);
        break;
      }
  }
  printSudoku(0.66);
}
Beispiel #4
0
void rotate90ccw()
{
  flipVert();
  rotate90cw();
}