Method for Compression of Image Data and Corresponding Apparatus and Computer-Program product