#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    57
    Rep Power
    0

    Shifting function


    I m using this function to shift elements of a matrix, to do this I m shifting between 1-3 quadrant and 2nd-4th .
    It works good whith even N ,but with odd N it doesn' t work for lastest elements.



    Code:
           void ftshifting(double **filter,int rows,int cols){
    
              int r2,c2,tmp1_3,tmp2_4;
    
              r2 = rows/2;
              c2 = cols/2;
    
    
              for (int i = 0; i<r2; i++){
                for (int k = 0; k<c2; k++){
     
                  tmp1_3 = filter[i][k];
                   filter[i][k] = filter[i+r2][k+c2];
                 filter[i+r2][k+c2] = tmp1_3;
    
                 tmp2_4 = filter[i+r2][k];
                 filter[i+r2][k] = filter[i][k+c2];
                 filter[i][k+c2] = tmp2_4;
                }
              }
            }
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    57
    Rep Power
    0
    I adjusted it and now it works

IMN logo majestic logo threadwatch logo seochat tools logo