fixed a gain scaling bug and now using abetter pixel intensity algo