Code for speeding up and make more automatic pixel calibration procedure