2
$\begingroup$

I'm trying to estimate what would be the result of first performing an histogram equalisation on an image, and then compressing it using JPEG.

I know that histogram equalisation increases the contrast in the image. I also know the jpeg reduces the size of the image by removing the high frequencies from the frequency domain. Thus, it seems reasonable to me that performing histogram equalisation first would result in loosing more information, as it would increase the higher frequencies in the photo only for them to be later removed by jpeg.

Am I correct? If no, what am I missing?

$\endgroup$
  • 1
    $\begingroup$ Probably better to keep the original image and equalize after decompression, if that is possible. $\endgroup$ – Yves Daoust Mar 18 '16 at 9:37
1
$\begingroup$

I did some experiments. Equalizing, then compressing, resulted in a nearly 50% larger file. Normalizing increased the filesize but not so much. Normalizing, then equalizing, also increased the filesize by nearly 50%. All are JPEG quality 50, created with ImageMagick:


- left: original (4540 bytes); right normalized (5467 bytes):

original.JPG normalized.JPG


- left: equalized (7444 bytes); right: normalized, then equalized (7251 bytes) equalized.JPG normalized+equalized.JPG

$\endgroup$
1
$\begingroup$

Equalization of an image tends to increase its sharpness, high frequency content, dynamic range and level utilization which are fundamentally against the compression algorithm that seeks longer zero valued quantized samples to group under a given huffman code... Hence as less number of samples fit into a group (inside a block) more bits are necessary to define that block resulting in increase of size of the file for example.

$\endgroup$
1
$\begingroup$

"I also know the jpeg reduces the size of the image by removing the high frequencies from the frequency domain"

Not exactly, it often reduces accuracy in the frequency domain, even more in the highest frequencies (due to the quantization tables), but not only.

What you are trying to do makes sense in one context: you have a fixed quality JPEG system, and you want to acquire images with low contrast, or tiny details, that would be lost with standard JPEG. Then you can amplify the data first, then compress, because this would preserve some details that would have been lost otherwise.

But there is not free lunch in general: you will loose quality on other aspects.

$\endgroup$
1
$\begingroup$

JPEG doesn't remove the high-frequency components of an image. It quantizes them more coarsely, allowing them to be represented in fewer bits. A lot of the high-frequency components are close enough to zero that they'll round to zero when quantized, and these are compressed even more efficiently.

When you equalize the image or perform other operations that enhance the high-frequency content, you make those components larger compared to the quantization steps. They will be represented with larger numbers, and more of the high-frequency information will be preserved. In addition, fewer of the high-frequency components will come out to zero, which will significantly increase the size of the compressed image.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.