Support 16 bit image.
Fix arbitrary floating point type.
Add template specialized code for unsigned char and unsigned short.