Wednesday, December 8, 2010

(4) PixelArray()

public int[][] pixelArray() {
rgbs = new int[wpixel*hpixel];
// System.out.println("rgbs length: " + rgbs.length);
int[][] pixelArrayData = new int[wpixel][hpixel];
int colorcounter = 0;

/* 24 bit color
16777216 = 2^24

16 bit color
65536 = 2^16

(2^24)/(2^24) = 1bit --> 0 or 1
(2^24) / (2^16) = 2^8bits --> 0-225
*/

inputSourceImage.getRGB(0, 0, wpixel, hpixel, rgbs, 0, wpixel);
for (int r=0;r<wpixel;r++) {
for (int c=0;c<hpixel;c++) {
pixelArrayData[r][c] = -(rgbs[colorcounter])/65536; //greyscale
colorcounter++;
// System.out.print(pixelArrayData[r][c]+ " ");
}
// System.out.println();
}
if (noiseOn){
pixelArrayData = addNoise(pixelArrayData,percentNoise);
}

/* System.out.println("WITH NOISE");

for (int r=0;r
for (int c=0;c
// System.out.print(pixelArrayData[r][c] + " ");
}
// System.out.println();
}*/

return pixelArrayData;
}

Part 3  <-- Back to Part 3

No comments:

Post a Comment