-2

Is it possible to iterate through multiple image files? For example, given the following code, iterate through "someImage.jpg" to someImage20.jpg"? I still want the code following the BufferedImage to execute for each image of course.

    BufferedImage image = ImageIO.read(new File("someImage.jpg"));
    for(int x = 0; x < image.getWidth(); x++)
        for(int y = 0; y < image.getHeight(); y++) {
            int color = image.getRGB(x, y);
            int alpha = (color & 0xff000000) >> 24;
            int red = (color & 0x00ff0000) >> 16;
            int green = (color & 0x0000ff00) >> 8;
            int blue = color & 0x000000ff;
            ch[red / 128][green / 128][blue / 128]++;   
kaneda
  • 5,981
  • 8
  • 48
  • 73

1 Answers1

0

You need to iterate through files in an outer loop. See instructions here: How do I iterate through the files in a directory in Java? and process each File with your code block.

Community
  • 1
  • 1