Corrected all errors relating to 8 bit vs 16 bit input image.