The fully adaptive prediction error coder (FAPEC) is an entropy coder that typically offers better results than the adaptive Rice compressor. It uses basic preprocessing stages such as delta preprocessing, but it can also be combined with a discrete wavelet transform. We describe a new algorithm called hierarchical pixel averaging (HPA). It divides an image into blocks of 16 x 16 pixels, which are subsequently divided into smaller blocks, up to the basic level where one block corresponds to one pixel. Average pixel values are determined for each level from which differential coefficients are extracted. HPA allows the introduction of controlled losses with several quality levels, also allowing to progressively decompress a given image from l...