Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

first I get Red, Green and Blue value from the following code,

  BufferedImage  image; 
  File input = new File("digital_image_processing.jpg");
     image = ImageIO.read(input);
     width = image.getWidth();
     height = image.getHeight();
      for(int i=0; i<height; i++){
        for(int j=0; j<width; j++){
           Color c = new Color(image.getRGB(j, i));
           int red = (int)c.getRed();
           int green = (int)c.getGreen() ;
           int blue = (int)c.getBlue() ;

Here After Getting the Red, Green and Blue value from getRGB(), I want to Do some modification with the Red, Green and Blue value then again I want to convert it to same RGB value, or create a new 2d array RGB for the combined Red, Green and blue value. How to do it?? Any Guess.. Pls. Help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
277 views
Welcome To Ask or Share your Answers For Others

1 Answer

Abdul's answer is great, but it can be really slow when creating new objects of class Color thousands of times. The simplest way would be:

int rgb = (red << 16 | green << 8 | blue);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...