Bonjour tout le monde;
j'essaye dans le code java suivant d'afficher les niveaux de gris d'une image niveaux de gris mais les valeurs affichées sont négatives alors qu'elles devaient être entre 0 et 255
quelqu'un peut m'aider?

Code java : 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
 
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
 
import javax.imageio.ImageIO;
import javax.swing.JFrame;
 
 
 
public class RegionGrowing {
	static BufferedImage img=null;
	public static  void main(String[] args)
	   { 
		RegionGrowing Region=new RegionGrowing();
       String name_file="c:\\ortrho25eparse.jpg";
/*loading image*/
       JFrame f = new JFrame("Load Image Sample");
 
       f.addWindowListener(new WindowAdapter(){
               public void windowClosing(WindowEvent e) {
                   System.exit(0);
               }
           });
 
         f.add(new LoadImag(name_file));
 
       f.pack();
       f.setVisible(true);
 
/////////** Finding starting points **/
 
/* 1.Thresholding Image*/
       BufferedImage S=null;;
       try {
		    S= ImageIO.read(new File(name_file));
 
	       } catch (IOException e) { System.out.println("erreur de nom de file");}
       /** Lecture de tous les pixels : */
       int colonnes = S.getWidth();
       int lignes = S.getHeight();
       int[] rgbs = new int[colonnes*lignes]; /** on crée l'espace neccessaire */
        S.getRGB(0,0,colonnes,lignes,rgbs,0,colonnes);
 
       for(int i=0;i<lignes*colonnes;i++) {
    	  System.out.println(rgbs[i]);
     } 
 
 
 
 
 
 
 
 
}
/* loading image*/
}
 
 
 class LoadImag extends Component{
		private static final long serialVersionUID = 1L;
		 BufferedImage img=null;
		 int rgb[];int rgbs[]; int w;
		public LoadImag(String name_file){
		try {
		    img = ImageIO.read(new File(name_file));
 
 
		} catch (IOException e) { System.out.println("erreur de nom de file");
		}
		}
 
		public void paint(Graphics g) {
	        g.drawImage(img, 0, 0, null);
	    }
 
	    public Dimension getPreferredSize() {
	        if (img == null) {
	             return new Dimension(100,100);
	        } else {
	           return new Dimension(img.getWidth(null), img.getHeight(null));
	       }
	    }
 
 
	}