move swapDim to NDimensional and use that in Chunk and Image