title: Cropping an Image Using 2D Arrays?
body: <p>I am completely lost on this assignment, any help would be appreciated guys! I am reading in a PGM image and making changes to it. I have already written some code to increase the brightness on it, but I don't know how to crop it.</p>
  
  <p>My brighten code for an example:</p>
  
  <pre><code>public static short[][] brighten(short[][] orig, short amount) {
  
      short[][] returnArray = new short[orig.length][orig[0].length];
      for(int i = 0; i &lt; orig.length; ++i){
          for(int j = 0; j &lt; orig[0].length; ++j){
              returnArray[i][j] = (short)(orig[i][j]+amount);
          }
  
      }
  
      return returnArray;
  }
  </code></pre>
  
  <p>So I have tried to use something like this but it doesn't seem to be working either:</p>
  
  <pre><code>public static short[][] crop(short[][] orig, int ULx, int ULy, int &gt;LRx, int LRy) {
  
      short[][] returnArray = new short[orig.length][orig[0].length];
      for (int i = ULx; i &lt;= LRx; i++) {
          for (int j = ULy; j &lt;= LRy; j++){
              returnArray[i][j] = (short)(orig[i][j]);
          }
      }
      return returnArray;
  }
  </code></pre>
  
  <p>Any suggestions?</p>