title: Converting a double scripted array of grayscale int values to a BufferedImage
body: <p>So after hours of searching I am ready to pull my hair out on this one.</p>
  
  <p>I am doing some research in Computer Vision and am working with grayscale images. I need to end up with an "image" (a double scripted double array) of Sobel filtered double values. My Sobel converter is set up to take in a double scripted int array (int[][]) and go from there.</p>
  
  <p>I am reading in a buffered image and I gather the grayscale int values via a method that I am 99% sure works perfectly (I can present it if need be).</p>
  
  <p>Next I am attempting to convert this matrix of int values to a BufferedImage by the below method:</p>
  
  <pre><code>private BufferedImage getBIFromIntArr(int[][] matrix){
  
      BufferedImage img = new BufferedImage(matrix.length * 4, matrix[0].length, BufferedImage.TYPE_INT_ARGB);
      - Gather the pixels in the form of [alpha, r, g, b]
      - multiply the size of the array by 4 for the model
      int[] pixels = new int[(matrix.length * 4 * matrix[0].length)];
      int index = 0;
      for (int i = 0; i &lt; matrix.length; i++) {
          for (int j = 0; j &lt; matrix[0].length; j++) {
              int pixel = matrix[i][j];
              pixels[index] = pixel;
              index++;
              for (int k = 0; k &lt; 3; k++) {
                  pixels[index] = 0;
                  index++;
              }
          }
      }
      -get the raster
      WritableRaster raster = img.getRaster();
      -output the amount of pixels and a sample of the array
      System.out.println(pixels.length);
      for (int i = 0; i &lt; pixels.length; i++) {
          System.out.print(pixels[i] + " ");
      }
     - set the pixels of the raster
      raster.setPixels(0, 0, matrix.length, matrix[0].length, pixels);
      - paint the image via an external routing to check works (does not)
      p.panel.setNewImage(img);
  
      return img;
  }
  </code></pre>
  
  <p>Here is my understanding. The ARGB Type consists of 4 values Alpha, Red, Green, and Blue. I am <em>guessing</em> that setting the alpha values in the new BufferedImage to the greyscale image int values (the matrix values passed in) then this will reproduce the image. Please correct me if I am wrong. So as you can see I create an array of pixels that stores the int values like this: [intValue, 0, 0, 0] repeatedly to try to stay with the 4 value model.</p>
  
  <p>Then I create a writable raster and set the gathered pixels in it using the gathered pixels. The only thing is that I get nothing in the BufferedImage. No error with the code below and Im sure my indeces are correct.</p>
  
  <p>What am I doing wrong? Im sure it is obvious but any help is appreciated because I cant see it. Perhaps my assumption about the model is wrong?</p>
  
  <p>Thanks,
  Chronic</p>