also implemented the inverse of the 'refinement' step
some changes to increase functionality
save png using savepng.m
some changes