Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ColorComponents{
- public static void main(String [] args){
- BufferedImage image = ImageIO.read(new File("black_&_white.jpg"));
- int width = image.getWidth();
- int height = image.getHeight();
- String [][] pixelsComponents=new String[width][height];
- for (int i = 0; i < width; i++) {
- for (int j=0; j < height; j++) {
- int pixel = image.getRGB(i,j);
- Color picColor =new Color(pixel);
- int red= picColor.getRed(),green=picColor.getGreen(),blue=picColor.getBlue();
- pixelsComponents[i][j]=red +" "green+" " +blue;
- }
- }
- //Print the array
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement