Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. public class ColorComponents{
  2. public static void main(String [] args){
  3. BufferedImage image = ImageIO.read(new File("black_&_white.jpg"));
  4.  
  5. int width = image.getWidth();
  6. int height = image.getHeight();
  7. String [][] pixelsComponents=new String[width][height];
  8.  
  9. for (int i = 0; i < width; i++) {
  10. for (int j=0; j < height; j++) {
  11.  
  12. int pixel = image.getRGB(i,j);
  13.  
  14. Color picColor =new Color(pixel);
  15. int red= picColor.getRed(),green=picColor.getGreen(),blue=picColor.getBlue();
  16.  
  17. pixelsComponents[i][j]=red +" "green+" " +blue;
  18.  
  19. }
  20. }
  21.  
  22. //Print the array
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement