bonjour !

je suis entrain d’écrire un code qui parcours une image et revoie un tableau où il stocke des donnée extraite de cette image !! ce tableau est de taille 13, 5 case pour la somme des ligne en horizontal, 5 autres cases pour la somme des colonnes en vertical, et enfin 3 case pr la moyen des couleur de l'image,une pour le rouge, la 2e pour le vert, et la dernière pr le bleu !

voilà le code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
 
import java.io.IOException;
import javax.imageio.ImageIO;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.awt.Color;
import java.awt.image.BufferedImage;
 
 
 
public class pix2 {
 
public static final String IMG = "C:/Users/loli/Desktop/orange.bmp";
 
public static void main(String[] args) {
 
    pix2 p;
    p = new pix2();
 
    BufferedImage img;
    try
    {
        img = ImageIO.read(new File(IMG));
        p.GetSignature(img);
    }
    catch(IOException e)
    {
        e.printStackTrace();
        return;
    }
 
    }
 
public double[] GetSignature(BufferedImage img) throws IOException
{
    double [] tabres= new double[13];
 
    byte tab[];
    tab = GetGrayImage(img);
 
    int[] tabSommeHorizontal;
    tabSommeHorizontal = GetSommesHorizontal(tab, img.getWidth(), img.getHeight());
 
    double[] tabSommeHorizontalN;
    tabSommeHorizontalN = Normalize(tabSommeHorizontal);
 
    int[] tabSommeVertical;
    tabSommeVertical = GetSommesVertical(tab, img.getWidth(), img.getHeight());
 
    double[] tabSommeVerticalN;
    tabSommeVerticalN = Normalize(tabSommeVertical);
 
    double [] tabMaxH =GetMax(tabSommeHorizontalN);
            double [] tabMaxV =GetMax(tabSommeVerticalN);
            int [] tabColor= GetMoyen(img);
 
    for(int i=0; i<5;i++)
        tabres[i]=tabMaxH[i];          
    for(int i=0; i<5;i++)
        tabres[i+5]=tabMaxV[i];
 
for(int i=0; i<3;i++)
tabres[i+10]=tabColor[i];
 
return tabres;
}
//moyen RGB de l'image
public int[] GetMoyen(BufferedImage img) throws IOException{
int [] tab = new int[3];
File f = new File(IMG);
 img = ImageIO.read(f);
int[] ib = img.getRGB(0, 0, img.getWidth(), img.getHeight(), null, 0, img.getWidth());
Color c = new Color(ib[0]);
 
int R=c.getRed();
int G=c.getGreen();
int B=c.getBlue();
 
tab[0]= R;
tab[1]= G;
tab[2]= B;
 
return tab;
}
//5 val max
public double[] GetMax(double [] tab){    double[] tab2 = new double[5];
 
    Arrays.sort(tab);
 
    for (int i=0; i<5; i++)
        tab2[i] = tab[i];
 
            return tab2;
}
//normalization
public double[] Normalize(int[] tab)
{
    int max = tab[0];
    for(int i=0;i<tab.length;i++)
    {
        if(tab[i] > max)
            max = tab[i];
    }
 
    double[] res = new double[tab.length];
 
    for(int i=0;i<res.length;i++)
    {
        res[i] = (double)tab[i]/(double)max;
    }
 
    return res;
}
//somme horizontale
public int[] GetSommesHorizontal(byte[] tab, int w, int h)
{
    int[] res = new int[h];
 
    for(int i=0;i<h;i++)
    {
        int somme = 0;
        for(int j=0;j<w;j++)
        {
            somme = somme + tab[i*w+j];
        }
        res[i] = somme;
    }
 
    return res;
}
 
//somme verticale
public int[] GetSommesVertical(byte[] tab, int w, int h){
    int[] res2 = new int[w];
    for(int j=0; j<w;j++){
        int somme=0;
        for (int i=0;i<h;i++){
            somme=somme+tab[i*w+j];
        }
    res2[j]=somme;
    }
    return res2;
}
//tableau niveau de gris
public byte[] GetGrayImage(BufferedImage img)
{int k=0;
 
    byte tab[]=new byte [img.getHeight() * img.getWidth()];
 
        int counter = 0;
        for(int i = 0; i < img.getWidth(); i++)
        {
            for(int j = 0; j < img.getHeight(); j++)
            {  
                int[] rgb;
                rgb = getPixelData(img, i, j);
 
                tab[k] = (byte)((rgb[0] + rgb[1] + rgb[2])/3);
 
                k++;} } 
 
 
    return tab;
}
//RGB de chaque pixel
private static int [] getPixelData(BufferedImage img, int x, int y) {
int argb = img.getRGB(x, y);
 
int rgb[] = new int[]{
    (argb >> 16) & 0xff, //red
    (argb >>  8) & 0xff, //green
    (argb      ) & 0xff  //blue
};
 
//System.out.println("rgb: " + rgb[0] + " " + rgb[1] + " " + rgb[2]);
return rgb;
 
 
}
}
le problème c'est que ce programme ne me renvoie rien même s'il ne génère aucune faute!! alors qu'il est supposé me renvoyer un tableau[13] !!

svp aidez moi !!!