changed invert and threshold to be done by PImage rather than opencv