After hours and hours of searching, I'm relying on your expertise! Please help!
Basically, I'm trying to access the data from individual pixels in a greyscale image.
Here's a link to the image I'm talking about:- http://s14.postimg.org/ak092kza5/WORKS.jpg?noCache=1382913709 (it should be all black. I am aware I could just color it in, but that's not what I want to learn - I want to find out how I can remove the noise!)
public static void handlesinglepixel(int x, int y, int pixel) {
int alpha = (pixel >> 24) & 0xff;
int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = (pixel) & 0xff;
// Deal with the pixel as necessary...
}
public static void handlepixels(Image img, int x, int y, int w, int h) {
int[] pixels = new int[w * h];
PixelGrabber pg = new PixelGrabber(img, x, y, w, h, pixels, 0, w);
try {
pg.grabPixels();
} catch (InterruptedException e) {
System.err.println("interrupted waiting for pixels!");
return;
}
if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
System.err.println("image fetch aborted or errored");
return;
}
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
handlesinglepixel(x + i, y + j, pixels[j * w + i]);
}
}
}
So using this I can access the individual pixels. I am really happy! But...I now want to compare the adjacent pixels to see if they are abnormally lighter than the other pixel. I'm doing this because I want to remove noise from a pic. Any advice?
P.S I tried using RescaleOp and changed the brightness factor of all pixels, then multiplied them down again, but it just made the image unrecogniseable. I'm really stuck as to how to remove the noise!
I look forward to reading your responses.