title: how to convert int to uint8 in java
body: <p>I write an image filter in Matlab and I want to translate it to java in order to use my android application. How can I convert short or int to uint8 data format. </p>
  
  <p>BTW:I know there is no type like uint8 in java.</p>
  
  <p>Any help will be greatly appreciated.</p>
  
  <p><strong>Matlab:</strong></p>
  
  <pre><code>for iX = 1:imageX
      for iY = 1:imageY
          x(1:3) = input(iX,iY,:);
          output(iX, iY, :) = uint8(p1.*x.^5 + p2.*x.^4 + p3.*x.^3 + p4.*x.^2 + p5.*x + p6);
      end
  end
  </code></pre>
  
  <p><strong>Java:</strong></p>
  
  <pre><code>for (int iX = 0; iX &lt; width; iX++) {
              for (int iY = 0; iY &lt; height; iY++) {
                  Arrays.fill(x, bitmap.getPixel(iX, iY));
                  short total = 0;
                  for (int i = 0; i &lt; 3; i++) {
                      total +=p1[i] * Math.pow(x[i], 5) + p2[i]
                              * Math.pow(x[i], 4) + p3[i] * Math.pow(x[i], 3)
                              + p4[i] * Math.pow(x[i], 2) + p5[i] * x[i] + p6[i];
                  }
                  output.setPixel(iX, iY, total);
              }
          }
  </code></pre>