2
$\begingroup$

As I understand the JPEG algorithm, it smooths (ignores) gradual variations in colour and brightness in favour of high frequencies. This loss of information is what creates the characteristic high level of compression relative to lossless algorithms.

So the grey square would result in a small JPEG file, whilst the grids should generate larger files:-

squaregrid1grid2

Clearly such grids /patterns could be of any pitch right up to single pixels. I'm stipulating that all the images are grey scale types. Is there some way to determine the type of pattern to maximise the size of a JPEG file, or must this be done experimentally?

$\endgroup$

marked as duplicate by endolith, Peter K. Sep 27 '17 at 14:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ Which encoder and encoder settings? The encoders are free to tune the quantization table for each image, and may not have equivalent encoding settings. $\endgroup$ – Olli Niemitalo Sep 27 '17 at 11:56
1
$\begingroup$

Pursuing on @OlliNiemitalo, JPEG allows some loss related to frequency quantization. So any file can be compressed to any size, hence you cannot maximize a JPEG size without setting some constraints, like quality. Let us assume a standard metric, like mean-squared error.

Now, let us check some of the JPEG features for image sparsification, and let us try to go the opposite direction:

  • JPEG assumes similarities in RGB color planes, correlated with a luminance/chrominance transform for instance. So you choose independent R, G, and B, you are good
  • 8$\times 8$ patches are compressed almost independently, except for the average, predicted for the blocks before (raster order). If you have neighboring blocks with very different means, good
  • the more the high-frequency, the less a 8$\times$8 block as natural frequency, the better. They avoid long trails of zeros encoded by an EOB symbol.

One cannot easily fulfill all these properties together, especially with RGB planes made of 8-bit integers. Forgetting about the average-thing, generating independent RGB images, with each pixel randomly $0$ or $255$ (ie high range). Quantization is likely to produced here a lot of false colors. This could give you very bad images for the JPEG in MSE. However, original and compressed ones could look as ugly.

You can find other fractal-based or fancy-patterned proposal in What is the least JPG-compressible pattern? (camera shooting piece of cloth, scale/angle/lighting may vary)

$\endgroup$
0
$\begingroup$

If you are looking for an explicit mathematical (analytic geometrical etc.) formula which would generate the geometrical shape (the pattern) that you define as the one which would compress least under a given JPEG encoder implementation; I haven't heard of such a formula. May be there is but as I said I haven't heard of one such.

However, the way you ask this question is not the most proper approach given the theoretical concepts behind the JPEG image compression algorithms. If you look at a generic JPEG encoder, you would see that there are a number of blocks such as the DCT, Quantizer and VLC Huffman encoder.

I won't go into the details of the theoretical analysis of those blocks and the mechanism of how the associated compression is physically achieved. However I will describe the charactheristic of the shape which would produce more bits than others under a given encoder:

The shape which would result in the largest JPEG encoded bitstream is the one, which, after its DCT is taken, produces least number of consequitive zeros and largest amplitude coefficients after the DCT coefficients are quantized by a selected weighting matrix.

So which image would do that? It depends on the weighting matrix and DCT. If you select a human visual system based weighting matrix then the image must have excess high frequency contets. This means that The image must be composed of sharp and short duration black and white passages.

Its orientation could also matter because of the zig-zag scannig pattern of eth DCT coefficients. But its hard to be sure without further analysis.

Consequently a white noise image with high dynamic range would produce quite large file size as its DCT would be ineffecitve to reduce its frequency content to low frequency coefficients.

$\endgroup$

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