in the middle of rewritting for use with int* images