Processing Forum
Applying the following code to convert from a grayscale image to threshold but the output would be a total black picture any ideas:
PImage toThreshhold(PImage sourcePic) { PImage thresh = new PImage(sourcePic.width,sourcePic.height); sourcePic.loadPixels(); for(int i = 0; i < sourcePic.width; i++) { for(int j = 0; j<sourcePic.height; j++){ int pixPosition = i*sourcePic.width +j; if(sourcePic.pixels[pixPosition] > 127) { sourcePic.pixels[pixPosition] = color(255); } else { sourcePic.pixels[pixPosition] = color(0); } } } sourcePic.updatePixels(); return thresh; }
