title: java.lang.IllegalArgumentException: More than one component per pixel
body: <p>I'm new to image processing in Java.  I'm trying to compare two images with the code below and getting the message following the code.  Any help is greatly appreciated.  Thanks.</p>
  
  <pre><code>    BufferedImage imgOrig = ImageIO.read(new URL(imgOrigUrl));
      BufferedImage imgComp = ImageIO.read(new URL(imgCompUrl));                
  
      byte[] pixelsOrig = ((DataBufferByte) imgOrig.getRaster().getDataBuffer()).getData();
      byte[] pixelsComp = ((DataBufferByte) imgComp.getRaster().getDataBuffer()).getData();
  
      //System.out.println("Number of pixels orig:"+pixelsOrig.length);
      //System.out.println("Number of pixels comp:"+pixelsComp.length);
  
      ColorModel cmImgOrig = imgOrig.getColorModel();
      ColorModel cmImgComp = imgComp.getColorModel();
  
      int sum1 = 0;
      int sum2 = 0;
      for(int i:pixelsOrig){
          System.out.println(cmImgOrig.getGreen(i));  //ERROR OCCURS HERE
          //System.out.println(i);
      }
  </code></pre>
  
  <p>ERROR:</p>
  
  <pre><code>Testcase: testCompareImages(com.myapp.img.compare.service.CompareServiceTest):  Caused an ERROR
  More than one component per pixel
  java.lang.IllegalArgumentException: More than one component per pixel
      at java.awt.image.ComponentColorModel.getRGBComponent(ComponentColorModel.java:594)
      at java.awt.image.ComponentColorModel.getGreen(ComponentColorModel.java:675)
      at com.scottmacri.img.compare.service.CompareService.compareImages(CompareService.java:42)
      at com.scottmacri.img.compare.service.CompareServiceTest.testCompareImages(CompareServiceTest.java:45)
  </code></pre>