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.
BTW:I know there is no type like uint8 in java.
Any help will be greatly appreciated.
Matlab:
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
Java:
for (int iX = 0; iX < width; iX++) {
for (int iY = 0; iY < height; iY++) {
Arrays.fill(x, bitmap.getPixel(iX, iY));
short total = 0;
for (int i = 0; i < 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);
}
}