Wie zeichnet man ein Histogramm mit einem RGB-Pixelwert?

Ich mache App in NetBeans-Plattform. ich möchte hisrogram zeichnen. Ich habe rote, grüne und blaue Farbpixel des Bildes. Also, bitte sagt mir jemand Bescheid, wie ich mit diesem Pixelwert ein Histogramm zeichnen kann. Mein Code ist unten, in dem ich ROT, GRÜN und BLAU Pixelwert des Bildes nehme.

<code> enter code here



    import java.awt.Component;
     import java.awt.image.BufferedImage;
     import java.io.File;
     import java.io.IOException;
     import javax.imageio.ImageIO;

      public class WalkImageTest10 extends Component {

      public static void main(String[] foo) throws IOException {
      WalkImageTest10 wa= new WalkImageTest10();
     }

      public void printPixelARGB(int pixel) {
      int alpha = (pixel >> 24) & 0xff;
      int red = (pixel >> 16) & 0xff;
      int green = (pixel >> 8) & 0xff;
      int blue = (pixel) & 0xff;

      System.out.println("argb: " + alpha + ", " + red + ", " + green + ", " + blue);
      //System.out.println(pixel);
     }

     private void marchThroughImage(BufferedImage image) {
     int w = image.getWidth();
      int h = image.getHeight();
      int pixel;
      System.out.println("width, height: " + w + ", " + h);

     for (int i = 0; i < h; i++) {
     for (int j = 0; j < w; j++) {
     //System.out.println("x,y: " + j + ", " + i);
     pixel = image.getRGB(j, i);
     printPixelARGB(pixel);
      //System.out.println("value of K:"+k+ " value of  pixel: " + pixel[j][i]);
     }
     }
System.out.println("loop is completed");
}

public WalkImageTest10() throws IOException {
// this is an image of a white spot on a black background.
// with the smoothing in the image it's of course not all black
// and white
BufferedImage image = 
ImageIO.read(new File("F:\\java\\aimages\\003.jpg"));
marchThroughImage(image);

}
}
</code>

Antworten auf die Frage(1)

Ihre Antwort auf die Frage