0

I am trying to make an ROC program in java. My problem is that when i want to normalize ( change the size of the letter thanks to a method which uses the matrix of pixels ). My letters are centered in a box of pixels. My code isn't working. I cannot find the problem.

Thank you for your help.

public static int[][] normalisation(int[][] data, int largeur, int hauteur){
    int [][] data2 = new int[data.length][data[0].length];
    for (int x = 0; x < data.length ; x++) {
        for (int y = 0; y < data[0].length ; y++) {
            data2[x][y]=255;
        }
    }      

    int a=0;
    int b=0;
    boolean bool = false;
    for (int i=0 ; i< data2.length-1; i++){
        for(int j=0 ; j < data2[0].length-1 ; j++){
            if(data[i][j]==0 && bool == false){
                a=i;
                bool=true;
            }
        }
    }
    for (int i=0 ; i< data2.length-1; i++){
        for(int j=0 ; j < data2[0].length-1 ; j++){
            if(data[j][i]==0 && bool == true){
                b=j;
                bool=false;
            }
        }
    }

    for (int i=a ; i< data2.length+a-1; i++){
        for(int j=b ; j < data2[0].length+b-1 ; j++){
            //System.out.println("i"+i +" j"+j +" (i*hauteur)/128: " + (i*hauteur)/128 + " (j*largeur)/128 :" + (j*largeur)/128 + " hauteur: " + hauteur + " largeur: " + largeur);                 if ( data[((i+1)*hauteur)/128][((j+1)*largeur)/128] == 0){
            data2[i-a][j-b]= data[((i+1)*hauteur)/data[0].length][((j+1)*largeur)/data.length];

        }
    }


    return data2;
}
  • What do you mean by ROC? Do you have a source for your algorithm? What exactly is not working? :) – user3001 Jun 03 '14 at 17:50
  • ROC is OCR optical character recognition . The source comes from a document of a friend of mine (in french and not on internet). Firstly i was using this algorithm without a and b but my image wasn't centered so i found that i needed to use my algorithm only on my letter without the white arround. But my problem is that i dont know how to shift the letter to have it centered. – user3704086 Jun 03 '14 at 18:41
  • Can't you just use a OCR library for Java? – user3001 Jun 04 '14 at 00:46

0 Answers0