title: How to calculate average pixel in two cosecutive peaks in x-signature
body: <p>I am working on latent fingureprint enhancement techniques.
  during implementation i have devide image 16X16 blocks and then get 32x16
  oriented window for each pixel(i,j) and calcualte the x-signature for each block centered
  at (i,j) now i stuck on point where i have to calculate the average number of 
  pixels in two consecutive peaks in x-signature but how?
  i was googling from last two days but not get any solution?</p>
  
  <p>This is the image i am working</p>
  
  <p><img src="https://i.stack.imgur.com/i8yYt.jpg" alt="enter image description here"></p>
  
  <p>which i have devided in to 16X16 blocks for further operation</p>
  
  <p>Following image is for Oriented window</p>
  
  <p><img src="https://i.stack.imgur.com/TECXI.png" alt="enter image description here"></p>
  
  <p>this is the formula for local ridge orientation at (i,j) which i have calulated in code given below</p>
  
  <p><img src="https://i.stack.imgur.com/YlRok.png" alt="enter image description here"></p>
  
  <p>this is formula to calculate x-signature at (i,j) calculated in code below
  <img src="https://i.stack.imgur.com/ghfgy.png" alt="enter image description here">)</p>
  
  <p>Now the frequency is computed by following formula</p>
  
  <p><img src="https://i.stack.imgur.com/pojtR.png" alt="enter image description here"> </p>
  
  <p>but the problem is how to calculate T(i,j)</p>
  
  <p>T(i,j) is average number of pixel in two consecutive peaks in x-signature</p>
  
  <p>below is my java code what i have done is</p>
  
  <pre><code>public static BufferedImage[] getOrientedBlocks(BufferedImage[] blocks16x16) {
               int wtheta=5;
               int w=32;   //blocks16x16 is array of 16X16 blocks of normalized image
              for (int m = 0; m &lt; blocks16x16.length; m++) {
  
                  BufferedImage imageblock = blocks16x16[m];
                  int width = imageblock.getWidth();
                  int height = imageblock.getHeight();
                  WritableRaster raster = imageblock.getRaster();
                  int[][] pixel = new int[width][height];
                  int[] array = new int[1];
  
                  int [][] Vx = new int[width][height];
                  int [][] Vy = new int[width][height];
                  int [][] theta = new int[width][height];
                  int [][]phix=new int[width][height];
                  int [][]phiy=new int[width][height];
                  int [][]phidashx=new int[width][height];
                  int [][]phidashy=new int[width][height];
                  int [][] O = new int[width][height];
                  int [][] filter = new int[width][height];
  
                  int [][] xsignature = new int[width][height];
  
                  for(int x=0;x&lt;width;x++)
                  {
                      for(int y=0;y&lt;height;y++)
                      {
                          raster.getPixel(x, y,array);
                          pixel[x][y]=array[0];
  
                      }
                  }
                  int M = getMean(pixel,imageblock);
                  int Sigma = getStanderDeaviation(pixel,M);
                  for(int i=0;i&lt;pixel.length;i++)
                  {
                      for(int j=0;j&lt;pixel[i].length;j++)
                      {
                          int x=0;
                          for(int u=(-wtheta/2);u&lt;(wtheta/2);u++)
                        {
                            for(int v=(-wtheta/2);v&lt;(wtheta/2);v++)
                            {
  
                                for(int p=(i-(u*w)-(w/2));p&lt;(i-(v*w)+(w/2));p++)
                                {
                                    for(int q=(j-(v*w)-(w/2));q&lt;(j-(v*w)+(w/2));q++)
                                            {
                                        Vx[p][q] = 2*(pixel[p][q-1] - pixel[p][q+1])*(pixel[p+1][q] - pixel[p-1][q]);
                                        Vy[p][q] =((int) Math.pow((pixel[p][q-1] - pixel[p][q+1]), 2))*(int) Math.pow((pixel[p+1][q] - pixel[p-1][q]),2);
                                        theta[p][q] = (int) ((1/2)*Math.atan(Vy[p][q]/Vx[p][q]));
                                        phix[p][q] = (int) Math.cos(2*theta[p][q]); 
                                        phiy[p][q] = (int) Math.sin(2*theta[p][q]); 
                                        filter[u][v] = getGaussianFilter(u,v,Sigma);
                                        phidashx[i][j] += filter[u][v]*phix[p][q];
                                        phidashy[i][j] += filter[u][v]*phiy[p][q];
                                       }
                                }
  
                            }
                        }
  
  
  
                        O[i][j] = (int) ((1/2)*Math.atan((phidashy[i][j])/phidashx[i][j]));
  
  
                        for(int k=0;k&lt;w;k++)
                      {
                      for(int d=0;d&lt;w-1;d++)
                      {  
                          int u=(int) ((i+(d-(w/2))*Math.cos(O[i][j]))+(k-1/2)*Math.sin(O[i][j]));
                          int v= (int) ((i+(d-(w/2))*Math.sin(O[i][j]))+(1/2-k)*Math.sin(O[i][j]));
                          raster=imageblock.getRaster();
                          int[] iArray=new int[1];
                          iArray[0]= O[i][j];
                          raster.getPixel(u, v, iArray);
                          x+=iArray[0];
  
  
                      }
                      }
  
  
                       raster=imageblock.getRaster();
                        int[] iArray=new int[1];
                        iArray[0]= x;
                        xsignature[i][j] = x;
                        raster.setPixel(i, j, iArray);
  
  
  
                      }
  
                  }
  
                  imageblock.setData(raster);
                  blocks16x16[m] = imageblock;
  
  
              }
              return blocks16x16;
  
  
  
          }
  </code></pre>