Img2ij

Bugfixes and added a  function that tries to automatically infer a mapping (used by the 3d viewer)