Compress JPEG files. Compress JPEG images. Free online JPEG compressor tool by PS2PDF. Reduce image size by selecting the desired target size or quality. You can convert multiple files and large image files very quickly. Change Compress Options (Optional) Output Extension. Compress JPEG, PNG, JPG image without loosing quality with high compression ratio best Image size reducer in kb Try For Free. Powered Compression Algorithm. Highcompress is the first in the market to used A.I ( Artificial Intelligence to compress images). High Compress is useful because it’s the only widely supported format that can.
- Compress Jpeg To Pdf
- Jpg Compress 200 Kb
- Compress Jpg Windows 10
- Jpg Compress 2 2 07
- Jpg Compress 2 2 0 3
- Jpg Compress 2 2 0 1
- Compress Jpg File online, free
v1.1.0 / 2 of 4 / 01 may 03 / greg goebel / public domain
* While compressing text files is useful, compressing still image files isalmost a necessity. A typical image takes up much more storage than atypical text message, and without compression images would be extremelyclumsy to store and distribute.
This chapter discusses ways to compress images, focusing on the JPEG (JointPhotographic Experts Group) specification for image compression.
[2.1] LOSSLESS & LOSSY IMAGE COMPRESSION[2.2] JPEG (1): LUMINANCE & CHROMINANCE IMAGE ENCODING / BLOCKS
[2.3] JPEG (1): SPECTRAL CONVERSION VIA DCT
[2.4] JPEG (3): QUANTIZATION / ZIG-ZAG SCAN / LOSSLESS OUTPUT ENCODING
[2.5] JPEG SUMMARY & STREAM FORMAT
[2.6] JPEG VARIANTS / JPEG-2000 / JBIG
[2.7] VECTOR & FRACTAL COMPRESSION
[2.1] LOSSLESS & LOSSY IMAGE COMPRESSION
* The increasing use of digitized images, particularly on the Internet, hasled to the need to compress such imagery to allow economical storage and fastdata transfer.
A digital image, or 'bitmap', consists of a grid of dots, or 'pixels', witheach pixel defined by a numeric value that gives its color. Images aredefined as either 'realistic', meaning photographs or realistic artwork withmany shades and few straight lines, or 'nonrealistic', meaning graphs, blockdiagrams, graphics banners, and cartoons with block colors and many straightlines.
The number of different colors available in a digital image is given by thenumber of bits assigned to each pixel. Common 'color resolutions' are 1 bitper pixel, for solid black-and-white nonrealistic images; 8 bits per pixel,for grayscale images, nonrealistic color images, and coarse realistic images;and 24 bits per pixel, for 'photographic quality' realistic images. 48 bitsper pixel is in increasing use for ultrahigh quality images.
An image stored in an uncompressed file format, such as the popular BMPformat, can be huge. An image with a pixel resolution of 640 by 480 pixelsand 24-bit color resolution will take up 640 * 480 * 24/8 = 921,600 bytes inan uncompressed format.
Lossless compression algorithms can be used to squeeze down images and thenrestore them again for viewing completely unchanged. The best known losslesscompressed image file scheme is Compuserve 'Graphics Interchange Format(GIF)', which uses a variation of the lossless LZW compression algorithm asoutlined in the previous chapter to compress images.
GIF has a few limitations. The first is that it cannot compress images withcolor resolutions greater than 8 bits. This is not a great problem withmonochrome images or with simple nonrealistic block color images likediagrams, but it is troublesome with color photographs, which are normally 24bits and have to be reduced in color. This is done either by selecting theclosest matching colors available in 8 bits, which can give 'off' results onoccasion; or by 'dithering', selecting a speckle pattern of two more morecolors that approximates an intermediate color, which tends to degrade theimage appearance.
The second problem is that the LZW algorithm has strings attached in the formof copyright protection that lead to periodic fears of legal obstructions toits use in GIF. For these and other reasons, a group of enthusiasts has nowcreated a new lossless compressed image file scheme known as 'PortableNetwork Graphics (PNG, pronounced 'ping')' that can compress images with24-bit or 48-bit color resolutions, and provides many other handy features.
PNG is an inspiring labor of love by a group of benign software guerrillaswho want it to be a success, but are not out to soak the users for it. PNGis based on freeware ZIP compression scheme to ensure that there will be nolegal obstacles to its use. PNG seems to be slowly catching on, and iscurrently supported by popular web browsers such as Netscape and MicrosoftInternet Explorer. In general it provides slightly better compression ratiosthan GIF.
* While lossless compression is a necessity for text files, it is not forimage files. Compression algorithms that involve a loss of image detail canprovide much higher compression ratios than lossless algorithms.
In fact, in a sense, there's no strong limit on how much compression can beobtained using a lossy compression scheme. It depends on how muchdegradation in image quality a user can tolerate. In the absurd case, abitmap image could be reduced to a single bit that specifies an all-black orall-white image, but nobody would really want to do this. There arepractical limits to the compression ratios that can be obtained by lossycompression.
The 'Joint Photographic Experts Group (JPEG)' specification has become thepractical standard for storing realistic still images using lossycompression. JPEG can generally give much higher compression ratios than GIFwhile retaining good image quality. Useful JPEG compression ratios aretypically in the range of about 10:1 to 20:1. JPEG can obtain highercompression ratios on images with high pixel resolutions, simply because thedegradation isn't as noticeable on a big image.
Compression ratios can be increased if higher degradation is tolerable. Mostsoftware that can create JPEG images, such as paint programs, allows the userto set a 'quality factor' to specify the percentage level of degradation.This quality factor is a more or less arbitrary scale and may not giveexactly the same results in different software packages, but as a rule a 75%percent quality factor gives a perfectly acceptable image, while qualityfactors above 95% buy very little improvement in the image, and qualityfactors below 10% produce a completely unacceptable image.
As will be explained in the following section, JPEG compresses the colorinformation, or 'chrominance', in an image separately from the actual detailsof shapes, or 'luminance'. Luminance amounts to a grayscale image, while thechrominance amounts to a wash of colors painted on top of that grayscaleimage. The eye is much more sensitive to the details of shapes than colorinformation, so the chrominance information can be compressed to a greaterlevel than the luminance information. This means that JPEG will usually havehigher compression ratios for color images than for grayscale images.
JPEG does not work very well for nonrealistic images, such as line drawingsand graphs, where a single wrong pixel is immediately obvious. In fact, JPEGdoes poorly at handling images that have straight lines or abrupt edges, anddoes not do a good job on text embedded in images either. GIF and PNG arenot only more appropriate for nonrealistic images such as line drawings, butcan also achieve higher compression ratios if the images are relativelysimple, with large block lettering, solid blocks of color, and so on.
JPEG is also not appropriate for storing images in a master archive as itcauses an immediate degradation of the image relative to its uncompressedformat. In addition, if the image is retrieved, modified, and then restoredas a JPEG, the degradation is likely to get worse.
Compress Jpeg To Pdf
[2.2] JPEG (1): LUMINANCE & CHROMINANCE IMAGE ENCODING / BLOCKS
* The JPEG committee was formed under the umbrella of the InternationalStandards Organization (ISO) in 1986, leading to the initial release of aspecification in 1991. The JPEG specification describes in general terms howto compress a digital image. It does not specify a particularimplementation.
In practice, JPEG is most often used to compress 24-bit color or 8-bitgrayscale images. The following discussion assumes that the JPEG coder iscompressing a 24-bit color bitmap image. Comments on how grayscale or lowcolor resolution images are handled are added at the end of the discussion.
This section and those following discuss the details of JPEG imagecompression. As it is very complicated, a summary is provided followingthese sections to review the main concepts.
* Each numeric value that describes the color of a pixel in a 24-bit colorimage actually breaks down into three values that define the exact color.There are two ways to define this set of three color values. Most of thecomputer literate are familiar with the 'RGB' color description scheme, whereeach pixel value is a set of by three numbers giving the red, green, and bluecolor value. For example, in RGB, each 24-bit value breaks down into three8-bit values, each giving the intensity of red, green, and blue in a scalefrom 0 to 255.
In the 'luminance-chrominance' scheme, used in traditional US analog colorTV, a pixel value is given by its grayscale brightness level, or 'luminance',and by a color value, or 'chrominance'.
Chrominance actually amounts to two values, one that describes the 'hue', orspecific color within a linear range of colors, and the other that describesthe 'saturation', or intensity of the color.
By the way, although chrominance is specified by two values, the actualvalues used aren't precisely the hue and the saturation. They're componentsof a two-dimensional vector, where the phase or angle of the vector gives thehue, and the magnitude of the vector gives the saturation. This indirectscheme is an artifact of the way the color signal is modulated in analogcolor TV broadcast. If this detail seems confusing, don't worry about it.You can just take it for granted that luminance is described by one value foreach pixel, and chrominance is described by a pair of values for each pixel.
Following TV usage, the luminance component is designated 'Y', and the twochrominance components are designated either as 'I' and 'Q', or 'U' and 'V',or 'Cr' and 'Cb'. For all I know these may actually represent differentformulas for chrominance, but if so it doesn't matter in this discussion.
The RGB and luminance-chrominance schemes are equivalent, and given one theother can be derived by some simple calculations. In principle, JPEGcompression can use either the RGB or luminance-chrominance scheme, but theluminance-chrominance scheme seems to be universal in practice, and thisdiscussion will assume its use.
* JPEG compression begins by converting the original two-dimensional imagedata array into three two-dimensional arrays, consisting of one array ofluminance data and two arrays of chrominance data. Each of these threearrays is then further divided up into a grid of two-dimensional arrays of 8rows of 8 pixels, giving 64 pixel values per block. These 8x8 'blocks' arethe target of JPEG encoding.
While computers display images using the RGB scheme, the pixel data isconverted to the luminance-chrominance scheme because it offers greaterpossibilities for compression. As mentioned earlier, this is because theluminance information contains most of the detail perceived by the human eye,while the overlying chrominance color information can be fuzzy withoutcausing any serious image degradation. The chrominance information reallyjust defines a tint overlaid on a grayscale image.
This means that JPEG doesn't necessarily need to keep all the chrominanceinformation, and the specification allows for a feature known as 'decimation'in which part of the chrominance information is simply thrown away.
For example, compression can be increased by only sampling every otherhorizontal pixel in a chrominance block, which cuts the number of chrominancebits in half. This is known as 'horizontal decimation', using a decimationfactor of 2, and results in one decimated 8x8 chrominance block for every twoluminance blocks.
Even more compression can be achieved by only sampling every other horizontaland vertical pixel in a chrominance block, which cuts the number ofchrominance bits to a fourth. This is known as 'horizontal and verticaldecimation' using a factor of 2, and results in one decimated 8x8 chrominanceblock for every four luminance blocks.
More sophisticated decimation algorithms, such as averaging, can be used, andit is possible to decimate by a factor of four. There is an odd nomenclaturefor designating decimated data. A block with no decimation is referred to as'4:4:4'; one with horizontal decimation only is referred to as '4:2:2'; andone with horizontal and vertical decimation is referred to as '4:2:0'.
[2.3] JPEG (1): SPECTRAL CONVERSION VIA DCT
* The first thing done to the 8x8 blocks in compression is to convert theirvalues into a 'spectrum'. To understand what this means and how it is done,for the moment arbitrarily assume that the block is from the luminancecomponent of the image. Actually, all three components are compressed in thesame way, but the luminance data provides the easiest example to visualize.
As you should know by now, the luminance data corresponds to a grayscaleversion of the original image. In more mathematical terms, the luminancedata defines a three-dimensional waveform or 'contour map' of the brightnessof the image in the block, with 'peaks' where the image is bright and'valleys' where it is dark.
The human eye can detect coarse details in the luminance image better than itcan detect fine details. This means that if the fine details aremathematically sorted out from a luminance block and thrown away to savestorage space, the image will (hopefully) still have an acceptableappearance.
This is the basic approach of the 'lossy' compression algorithm used by JPEG.The trick is figuring out how to sort out the fine details so they can bediscarded.
This is done through 'Fourier analysis'. According to Fourier analysis, anywaveform can be broken down into a set of pure sinusoidal waveforms ofvarying frequency and amplitude. This is done by a mathematical 'frequencydomain transform' operation, which converts the input waveform into a list ofamplitude values, or 'coefficients', for each pure sinusoidal value thatmakes up the original waveform. The list of coefficients is known as a'spectrum'.
In the current example, running the 8x8 block of luminance values through afrequency domain transform results in an 8x8 block of frequency coefficients.The low frequency coefficients correspond to the coarse details of the block,while the high frequency coefficients correspond to the fine details of theblock. In principle, high compression ratios can be obtained, at the expenseof fine details, by throwing away high frequency coefficients, with increasedcompression obtained by throwing away more coefficients.
In practice, JPEG doesn't actually throw the high frequency coefficientsaway. As will be explained momentarily, it just coarsens them, but the basicidea is the same.
* By the way, the usual way to think of a frequency domain transform is thatit converts a waveform that is a function of time into a set of amplitudesfor frequency components that can, in principle, be expressed in hertz. Forexample, in the frequency analysis of musical sounds, a complicated musicalsignal is broken down into a set of coefficients describing the simple soundwaves that make it up in terms of their amplitudes and frequencies.
However, in JPEG image compression the luminance values are just a set ofpixels that could represent anything. This means that the sinusoidal valuesin the spectrum obtained from the lumninance data are not expressed in hertz.They only have 'wavelengths' measured in terms of number of pixels andcorresponding array elements in the original luminance data, not time, andthe spectrum is only defined as as multiples of a starting (or 'fundamental',or 'base') frequency. These multiples are known as 'harmonics'.
Furthermore, the spectrum is simply a set of coefficient values giving theamplitudes of the harmonic components. The actual harmonics the coefficientsrefer to are defined by the array indexes.
If this sounds baffling, a simple example should help make it clear. Let'sconsider of converting a single row of a luminance block into a spectrumstored in an array with indexes from 0 to 7. The resulting data looks likethis:
- Array index 0: This is the 'zeroth harmonic' or 'constant component', discussed in a bit more detail below.
- Array index 1: Gives the amplitude coefficient of the base harmonic.
- Array index 2: Gives the coefficient for the second harmonic, with half the wavelength (twice the frequency) of the base harmonic.
- Array index 3: Gives the coefficient for the third harmonic, with 1/3rd the wavelength (3 times the frequency) of the base harmonic.
- Array index 4: Gives the coefficient for the fourth harmonic, with 1/4th the wavelength (4 times the frequency) of the base harmonic.
- Array index 5: Gives the coefficient for the fifth harmonic, with 1/5th the wavelength (5 times the frequency) of the base harmonic.
- Array index 6: Gives the coefficient for the sixth harmonic, with 1/6th the wavelength (6 times the frequency) of the base harmonic.
- Array index 7: Gives the coefficient for the seventh harmonic, with 1/7th the wavelength (7 times the frequency) of the base harmonic.
The element with index 0, referred to as the 'zeroth harmonic', doesn'trepresent a sinusoidal waveform. It represents a constant value, which is a'degenerate case' of a sinusoidal waveform. The zeroth harmonic is theaverage value of the waveform, and so is also called the 'constantcomponent'.
Of course, in the actual case of converting a luminance block to a spectrum,we actually end up with a two dimensional spectrum stored in an array with64 elements and indexes from (0,0) to (7,7). The element with the indexes(0,0) is, once more, the zeroth harmonic or constant component, and is aconstant value that gives the average brightness of the original luminanceblock.
All the other array elements give the coefficients of harmonics. The arrayelement with the index (0,1) gives the coefficient of the base harmonic thatonly varies in the horizontal direction, the element with (1,0) gives thecoefficient of the base harmonic that only varies in the vertical direction,and the element with index (1,1) gives the coefficient of the base harmonicthat varies in both directions.
Similarly, other indexes give the coefficients of appropriate combinationsof higher harmonics in either direction, finally ending with the arrayelement with index (7,7). This element gives the coefficient of the seventhharmonic in both directions.
* The best known frequency domain transform is the Fourier transform and itsvarious digital implementations, particularly the 'fast Fourier transform(FFT)'. However, JPEG compression uses a different but similar transformknown as the 'discrete cosine transform (DCT)'.
The FFT and the DCT give similar results, except for the way they handleendpoints. For a simplified example, consider an one-dimensional luminancewaveform made up of eight points that looks like this:Running this waveform through an FFT, eliminating some of the high frequencycomponents, and converting it back to a waveform again with an 'inverse FFT(IFFT)' gives something like:In comparison, running the waveform through a DCT, trimming off some of thehigh frequency components, and converting it back to a waveform again with an'inverse DCT (IDCT)' gives something closer to the original straight line:This example uses an eight-point one-dimensional waveform for simplicity, butthe same principle applies to the 8x8 two-dimensional DCT used in JPEGcompression.
* The precise details of the DCT are beyond the scope of this article, wouldmake the discussion far more complicated, and are more appropriate to adocument on signal processing. However, as mentioned earlier, the end resultof performing a DCT on an 8x8 block of luminance values is an 8x8 block ofharmonic coefficients for a set of implied two-dimensional sinusoidalwaveforms.
Incidentally, if you do a 'zoom' with a paint program to inspect the pixelsof a JPEG image stored with a high compression ratio, you can actually see'JPEG artifacts' that reflect these harmonics, such as checkerboard orstaggered-bar patterns. At high compression ratios, the high frequencyharmonic information has been degraded and no longer conceals the lowerharmonic patterns.
What is particularly fascinating is that for normal viewing the actual imagecan often look just fine even with all these artifacts, though they becomeincreasingly obvious as the quality factor is lowered and the compressionratio increased.
[2.4] JPEG (3): QUANTIZATION / ZIG-ZAG SCAN / LOSSLESS OUTPUT ENCODING
* By the way, the coefficient block that results from the DCT is equivalentto the original luminance block. No information has been thrown away. Ifyou run the coefficient block back through an IDCT, aside from normal smallcomputer calculation roundoff errors, you get the original luminance blockagain.
The next step in the compression process, known as 'quantization', is the onethat throws away information. Since the eye is less sensitive to highharmonics (fine details) in an image than low harmonics (coarse details), itis also less sensitive to alterations in the high harmonics, and thecoefficients of the high harmonics can be represented with fewer bits thanthe lower harmonics.
For example, suppose the values in the coefficient block are all 8 bitintegers, representing values from 0 to 255. For the lowest harmonics, wecan keep the values at 8 bits. For the highest harmonics, we could, forexample, convert the values to 4 bits, representing values from 0 to 15,saving half the storage for these coefficients. This is the 'coarsening'referred to earlier.
The conversion can be done by dividing the original 8-bit value by 16 andthrowing away the remainder, which a computer can do with a trivial shiftoperation. For example, if a high harmonic coefficient has a value of 137,dividing by 16 gives a value of 8. This will be restored to a value of 8 x16 = 128 by the uncompression process, which is a reasonable approximation.
Given 8-bit coefficient values, the 'quantization factor' can range from avalue of 1, meaning no loss, to 128, which compresses the coefficient valueto a single bit. The quantization factor is different for each of the 64coefficients in the block. JPEG uses a single 64-element table ofquantization factors, or 'Q table', to store the values for quantization,with the same table applied to all the blocks.
The quantization factors are not fixed. Adjusting the quality value forstoring a JPEG adjusts the quantization factors for the coefficient block,trading off compression ratio for image quality.
* Once a block has been converted to a spectrum and quantized, the JPEGcompression algorithm then takes the result and converts it into a onedimensional linear array, or 'vector', of 64 values, performing a 'zig-zag'scan by selecting the elements in the numerical order indicated by thenumbers in the grid below:This places the elements of the coefficient block in a reasonable order ofincreasing frequency. Since the higher frequencies are more likely to bezero after quantization, this tends to group zero values in the high end ofthe vector. The vector is then compressed using traditional losslesscompression algorithms.
Actually, just to make things confusing again, the first element of thevector, which stores the quantized coefficient for the constant component ofthe luminance block, is compressed differently from the other 63 quantizedcoefficients, and after that they both go through a second stage ofcompression. JPEG seems to leave no stone unturned in its search for highcompression ratios.
The idea of compressing the first element separately is particularly bafflingat first sight, since there's only one value and that wouldn't seem to offermuch room for compression. The trick is that the compression is performedbetween the DC terms of consecutive blocks, using 'delta modulation'.
Since the DC term doesn't change much from luminance block to neighboringluminance block, then the difference between the values of the coefficientsof the DC term for the two blocks is usually small. In delta modulation,only the difference between the two coefficients is stored. Of course the DCterm coefficient for the very first block is compared to a value of 0.
The other 63 values in the vector are compressed as a group, not compressedrelative to vectors derived from neighboring blocks. The compression isperformed with RLE, which takes advantage of the clustering of zero values bythe zig-zag scan. Once the quantized coefficients have gone through theirfirst stage of lossless encoding, they go through the second stage ofcompression using Huffman coding.
JPEG permits the use of a default Huffman table, or custom Huffman tablesderived specifically from the data in the image being compressed. Use of adefault Huffman table will very likely give poorer compression than use ofcustom Huffman tables, but the default tables won't have to be stored withthe rest of the data, so there's a trade-off.
* Although this discussion has focused on compressing the array of luminancevalues, the same process is used to compress the two arrays of chrominancevalues as well. The only differences are that chrominance data may bedecimated, as discussed earlier, and the chrominance values may have theirown Q-tables.
In any case, decompressing the encoded image uses exactly the reverse stepsof the process described above: Huffman decoding; RLE and delta-modulationdecoding; unpacking from a vector format to a block format; dequantizing;IDCT; reassembly of blocks into a full image component; and reassembly of theimage components into the image.
* Of course, compressing a grayscale image is equivalent to compressing justthe luminance component. However, it appears that JPEG cannot compress acolor image with 8-bit color resolution, at least not as such. As best as Ican figure out, this is because JPEG can only compress a color bitmap that isa 'true color' image, while a color bitmap with 8-bit color resolution is'color mapped'.
In a true color image, such as a bitmap with 24-bit color resolution, thevalue for each pixel actually gives the pixel color as an RGB value. In acolor-mapped image, the value for each pixel is an index into a table of 256RGB values, known unsurprisingly as a 'color map'.
The RGB values in the color map may be 12 or more bits of color resolution.This allows an 8 bit color bitmap to have access to a wide range of colors,but the trick is that it can only use 256 different colors from that rangeat one time. The selection of 256 colors is known as a 'palette'. An imagefile for a color mapped image consists of a grid of indexes, one for eachpixel, plus a table of color map values defining the palette.
This is why strange things happen when cutting and pasting 8-bit color imagesin paint program. If you have two different 8-bit color images, each willusually have a different palette. If you cut an item from one and paste itinto the other, the colors in the pasted item will often look very strange,since the image into which it is pasted has a different palette and theindexes for the pasted element are now pointing to the wrong colors.
Naturally, this doesn't happen with 24-bit color or other true color images,since they don't use a color map. You can cut and paste between two imagesand the results look fine.
Anyway, JPEG compression requires that the bitmap image provide RGB values soit can convert them into luminance and chrominance components. The pixelvalues for an 8-bit color bitmap aren't RGB values, they're indexes. TheJPEG coder will use the indexes and the color map data provided with theimage to produce a true color image, and then compress it. While reducingcolor image resolution from 24 bits to 8 bits will reduce file size by afactor of three for uncompressed images and will have at least that mucheffect on images compressed with typical lossless methods, it has no effectwith JPEG since the 8 bits get converted back into 24 and all you've done islose colors in your image.
[2.5] JPEG SUMMARY & STREAM FORMAT
* JPEG compression is confusing, as even JPEG advocates will , so a summarymay help make matters clearer. JPEG compression follows these steps:
- Separate a color image array into one luminance array and two chrominance arrays. The chrominance arrays may be decimated to achieve higher compression ratios. A grayscale image is equivalent to a luminance array without the two chrominance arrays.
- Break the arrays into 8x8 blocks.
- Perform a discrete cosine transform (DCT) on the blocks to obtain blocks of corresponding harmonic coefficients.
- Quantize the values in each coefficient block using a quantization table with scaling values for each element in the block.
- Convert the quantized coefficient block into a 64-element linear array using 'zig-zag scan'.
- Compress the first (constant) element in the linear array by performing delta modulation between arrays.
- Compress the other 63 elements of a single block using lossless run length encoding (RLE).
- Perform Huffman coding on the all the results.
The result of the compression is a stream of compressed data, which could bestored as a file or sent over a communications link. The structure of theJPEG stream follows directly from the compression algorithm.
The stream starts with a 'start of image' flag and ends with an 'end ofimage' flag. The contents between these flags define a 'frame', which givesthe entire image, which is structured as follows:
- The frame starts with miscellaneous tables including custom Huffman tables, quantization tables, and so on.
- The tables are followed by a header giving the bitmap image size, width, depth, and so on.
- The header is followed in turn by a series of 'scans', each giving a component of the image. Each scan consists of tables, followed by a descriptive header, and then 'segments', which are arrays of encoded 8x8 blocks.
[2.6] JPEG VARIANTS / JPEG-2000 / JBIG
* There are a number of variations on the basic JPEG compression scheme. Themost important is 'progressive JPEG', which is basically the same as standardJPEG except that it allows an image to be progressively displayed in greaterdetail as it is downloaded. There are a number of approaches to progressiveencoding, but one of the most straightforward is to send the constantcomponents of the blocks first, then keep sending higher harmonics, makingthe image increasingly clear.
There are 'lossless JPEG' specifications as well, which as their nameindicates, compress without throwing any detail away. Unsurprisingly, theydon't use the same compression techniques as lossy JPEG, and as they are notin widespread use they will not be discussed further here.
There is also a 'hierarchical' JPEG mode, which is used for encoding imagesfor presentation on a smaller display, and 'Motion JPEG', which is used forencoding video by using JPEG compression on individual frames. Neither ofthese appear to be in much use. Motion JPEG is clearly inferior to thepopular MPEG video compression spec in terms of compression ratios. MPEG,discussed in the next chapter, has some similarities to JPEG but involves useof delta modulation, generally sending changes in images from video frame tovideo frame rather than full frames, allowing it to obtain much greatercompression.
Various different implementations of Motion JPEG appear to be in some use invideo editing systems, since the delta modulation scheme used by MPEG tendsto make video splicing a little more troublesome.
* JPEG compression is based on the DCT, a form of sinusoidal transform.There is another class of transforms, based on functions known as 'wavelets',that instead of sinusoidal functions use sets of functions that resemblejagged pulses. They can in principle represent a time domain waveform withfewer coefficients than sinusoidal functions.
A new version of JPEG, named 'JPEG 2000', that replaces the DCT with awavelet transform, has now been introduced. The ISO JPEG 2000 committeeofficially released the specification in 2001 under the designation of 'ISO15444'. Software supporting the new image format is now gradually becomingavailable, though at last notice it wasn't supported by Web browsers, whichwould clearly signal its coming-of-age. However, some organizations' havemade noises about patent issues on the original JPEG specification. Thesepatents don't apply to JPEG 2000 and so such actions may drive introductionto the new specification.
As with traditional JPEG, JPEG 2000 begins by converting an RGB image into aluminance-chrominance image, and the chrominance information can be decimatedif desired. The resulting data is then split into subarrays or 'tiles',which are wavelet-transformed to the desired number of wavelet terms. Thisdata in turn is 'sliced and diced' in a complicated fashion and put throughthree levels of arithmetic coding to produce 'packets' that make up JPEG 2000stream. The packets are organized in such a way that a substream could beselected to give a smaller 'thumbnail' image, or a reduced-quality image, ora monochrome image, or whatever.
JPEG 2000 is estimated to give about 20% better compression than traditionalJPEG. Comparisons of the same image stored in JPEG and JPEG 2000 format withquality settings to give the same file size show a startling improvement inimage quality, with most of the notorious ugly JPEG artifacts simplydisappearing in JPEG 2000.
An enhancement known as 'mixed-raster content' is under considerationfor JPEG-2000, in which a coder will switch compression algorithms to, forexample, allow crisper compression of blocks of text, which tend to have ablurry appearance in the current JPEG implementation. Another enhancement isbuilt-in support for Motion JPEG, allowing a JPEG image to incorporate'metadata' that describes the order and speed of frame presentation.
* JPEG is a grossly inefficient scheme for compressing black and white, or'bilevel', images, since they have to be converted to 24 bits, and so adifferent specification, known as 'JBIG', has been devised to address thatissue. It has little do to with JPEG in terms of implementation, and isreally a complementary specification rather than a variation on JPEG.Details are beyond the scope of this document.
[2.7] VECTOR & FRACTAL COMPRESSION
* Some other compression schemes, such as vector quantization and fractalcompression, have some interest value, though they are not in common use.
For a conceptual explanation of vector quantization, suppose a black andwhite image is broken down into 8x8 blocks as in JPEG quantization. Supposealso that an encoder, and its corresponding decoder, have a 'library' of 256or more blocks that approximate the actual pattern in any arbitrary imageblock. It would be possible to obtain an 8:1 compression ratio by matchingeach block in the image with a block in the library, and just sending a codebyte designating which block in the library matches the image block.Compression could be increased by using some type of lossless compression onthe coded bytes.
* Fractal compression is based on transform mathematics, but the approach isvery different from that of conventional frequency analysis.
Fractals are geometric figures based on recursive expansion of a basicgeometric figure. For example, the Sierpinski Triangle is a fractal patternthat consists of a small triangle built up hierarchically as follows:Figure 1 on the left consists of a basic triangle. Figure 2 is a trianglebuilt from three basic triangles. Figure 3 is built from three of the secondfigures, or nine basic triangles, while figure 4 is built from three of thethird figure, or nine of the second figure, or 27 basic triangles.
This is a very simple fractal and it is hard to see what it has to do withimage compression, but a more sophisticated fractal can be used to build arealistic image of a fern leaf, where the fronds of the leaf look like theleaf itself, and on on down to the limit of graphics resolution. Fractalsare said to be 'self similar', meaning that if you look at a small part ofthe image, such as one of the fronds of the fern leaf, it looks like theentire image of the fern leaf.
Fractal patterns are well suited for representation of hierarchical objectslike trees, or objects like clouds, mountains, or coastlines that reveal alower level of 'self similar' detail at closer focus. Fractals have oftenbeen used in computer graphics videos, as they tend to provide pleasing and,in some cases, highly lifelike images. The well-known 'Genesis Torpedo'computer video segment from the movie STAR TREK 2: THE WRATH OF KAHN is oneof the best known examples of fractal computer graphics, with a wave of firesweeping over a barren planet that then becomes covered with life.
Given that fractal patterns can be used to generate images of objects, it'snot too big of a jump to suspect that an arbitrary image could be broken downinto a series of fractal patterns. This opens the possibility of extremelyhigh image compression ratios. The image would be analyzed to determine thefractal patterns that make it up and transformed into relatively small andcompact sets of parameters that define the proper fractal algorithms, Theparameters could then be further compressed with some lossless compressionalgorithm, in principle resulting in a very compact graphics file.
* Fractal compression is not a new idea. It goes back to the late 1980s andan organization named Iterated Systems, which was founded by severalmathematicians from the Georgia Institute of Technology. The scheme isconfronted by two obstacles: first, figuring out transform operations thatcan convert an arbitrary image element into a fractal, and second, performingthese operations in a reasonable amount of time, as they tend to be verycomputation-intensive.
The first problem, converting an image into a fractal algorithm, turned outto be particularly difficult, and in fact Iterated Systems was accused offraud by some critics. Using a fractal algorithm to produce a pretty fernleaf is one thing, but taking a real-life fern leaf with its manyimperfections and converting it to a fractal algorithm is another thingentirely, and although there are many objects in the real world that havefractal properties, many of them don't.
Critics referred to the original scheme for transforming an image into afractal as the 'graduate student algorithm'. It involved locking a graduatestudent into a room with a graphics workstation until he or she had come upwith the appropriate fractal algorithm to recreate the image. Automatedmethods have been devised, but the critics are still suspicious, though ithas to be noted that data compression hacks tend to be critical andquarrelsome in general and it is difficult to know how seriously to take themsometimes.
Fractal compression advocates claim the technique can provide 'resolutionenhancement', meaning that if an image compressed with fractal encoding isenlarged, it's still detailed. This is a bit slippery because this onlyreally applies to elements that have a fractal appearance where the conceptof self-similarity applies. That is, if you have an image of a cloud, whichis a fractal form, and enlarge it tremendously, it still looks like a prettygood image of a cloud.
However, all that additional detail is a fabrication, created by the fractalalgorithm. If there were an original image available at the same scale, thefine details would be different. The resolution enhancement breaks downseriously for elements that do not have a fractal appearance. As the sayinggoes, you really can't get something for nothing.
All the controversy aside, fractal compression is typically verytime-consuming, though decompression is relatively straightforward as itsimply requires chugging through the fractal algorithms, not determining whatthey are in the first place. In practice, so far fractal compression has notprovided significantly higher compression ratios than, say, JPEG.
Fractal compression is a very interesting concept, but its current status isuncertain. Fractals are not as sexy a concept now as they were in the 1980s,when everyone overdosed on psychedelic Mandelbrot set pictures. Whatever itsfacts of the case, I'm not inclined to hold my breath waiting for fractalcompression to take over the world.
Jpg Compress 200 Kb
v1.1.0 / 2 of 4 / 01 may 03 / greg goebel / public domain
* While compressing text files is useful, compressing still image files isalmost a necessity. A typical image takes up much more storage than atypical text message, and without compression images would be extremelyclumsy to store and distribute.
This chapter discusses ways to compress images, focusing on the JPEG (JointPhotographic Experts Group) specification for image compression.
[2.1] LOSSLESS & LOSSY IMAGE COMPRESSION[2.2] JPEG (1): LUMINANCE & CHROMINANCE IMAGE ENCODING / BLOCKS
[2.3] JPEG (1): SPECTRAL CONVERSION VIA DCT
[2.4] JPEG (3): QUANTIZATION / ZIG-ZAG SCAN / LOSSLESS OUTPUT ENCODING
[2.5] JPEG SUMMARY & STREAM FORMAT
[2.6] JPEG VARIANTS / JPEG-2000 / JBIG
[2.7] VECTOR & FRACTAL COMPRESSION
[2.1] LOSSLESS & LOSSY IMAGE COMPRESSION
* The increasing use of digitized images, particularly on the Internet, hasled to the need to compress such imagery to allow economical storage and fastdata transfer.
A digital image, or 'bitmap', consists of a grid of dots, or 'pixels', witheach pixel defined by a numeric value that gives its color. Images aredefined as either 'realistic', meaning photographs or realistic artwork withmany shades and few straight lines, or 'nonrealistic', meaning graphs, blockdiagrams, graphics banners, and cartoons with block colors and many straightlines.
The number of different colors available in a digital image is given by thenumber of bits assigned to each pixel. Common 'color resolutions' are 1 bitper pixel, for solid black-and-white nonrealistic images; 8 bits per pixel,for grayscale images, nonrealistic color images, and coarse realistic images;and 24 bits per pixel, for 'photographic quality' realistic images. 48 bitsper pixel is in increasing use for ultrahigh quality images.
An image stored in an uncompressed file format, such as the popular BMPformat, can be huge. An image with a pixel resolution of 640 by 480 pixelsand 24-bit color resolution will take up 640 * 480 * 24/8 = 921,600 bytes inan uncompressed format.
Lossless compression algorithms can be used to squeeze down images and thenrestore them again for viewing completely unchanged. The best known losslesscompressed image file scheme is Compuserve 'Graphics Interchange Format(GIF)', which uses a variation of the lossless LZW compression algorithm asoutlined in the previous chapter to compress images.
GIF has a few limitations. The first is that it cannot compress images withcolor resolutions greater than 8 bits. This is not a great problem withmonochrome images or with simple nonrealistic block color images likediagrams, but it is troublesome with color photographs, which are normally 24bits and have to be reduced in color. This is done either by selecting theclosest matching colors available in 8 bits, which can give 'off' results onoccasion; or by 'dithering', selecting a speckle pattern of two more morecolors that approximates an intermediate color, which tends to degrade theimage appearance.
The second problem is that the LZW algorithm has strings attached in the formof copyright protection that lead to periodic fears of legal obstructions toits use in GIF. For these and other reasons, a group of enthusiasts has nowcreated a new lossless compressed image file scheme known as 'PortableNetwork Graphics (PNG, pronounced 'ping')' that can compress images with24-bit or 48-bit color resolutions, and provides many other handy features.
PNG is an inspiring labor of love by a group of benign software guerrillaswho want it to be a success, but are not out to soak the users for it. PNGis based on freeware ZIP compression scheme to ensure that there will be nolegal obstacles to its use. PNG seems to be slowly catching on, and iscurrently supported by popular web browsers such as Netscape and MicrosoftInternet Explorer. In general it provides slightly better compression ratiosthan GIF.
* While lossless compression is a necessity for text files, it is not forimage files. Compression algorithms that involve a loss of image detail canprovide much higher compression ratios than lossless algorithms.
In fact, in a sense, there's no strong limit on how much compression can beobtained using a lossy compression scheme. It depends on how muchdegradation in image quality a user can tolerate. In the absurd case, abitmap image could be reduced to a single bit that specifies an all-black orall-white image, but nobody would really want to do this. There arepractical limits to the compression ratios that can be obtained by lossycompression.
The 'Joint Photographic Experts Group (JPEG)' specification has become thepractical standard for storing realistic still images using lossycompression. JPEG can generally give much higher compression ratios than GIFwhile retaining good image quality. Useful JPEG compression ratios aretypically in the range of about 10:1 to 20:1. JPEG can obtain highercompression ratios on images with high pixel resolutions, simply because thedegradation isn't as noticeable on a big image.
Compression ratios can be increased if higher degradation is tolerable. Mostsoftware that can create JPEG images, such as paint programs, allows the userto set a 'quality factor' to specify the percentage level of degradation.This quality factor is a more or less arbitrary scale and may not giveexactly the same results in different software packages, but as a rule a 75%percent quality factor gives a perfectly acceptable image, while qualityfactors above 95% buy very little improvement in the image, and qualityfactors below 10% produce a completely unacceptable image.
As will be explained in the following section, JPEG compresses the colorinformation, or 'chrominance', in an image separately from the actual detailsof shapes, or 'luminance'. Luminance amounts to a grayscale image, while thechrominance amounts to a wash of colors painted on top of that grayscaleimage. The eye is much more sensitive to the details of shapes than colorinformation, so the chrominance information can be compressed to a greaterlevel than the luminance information. This means that JPEG will usually havehigher compression ratios for color images than for grayscale images.
Compress Jpg Windows 10
JPEG does not work very well for nonrealistic images, such as line drawingsand graphs, where a single wrong pixel is immediately obvious. In fact, JPEGdoes poorly at handling images that have straight lines or abrupt edges, anddoes not do a good job on text embedded in images either. GIF and PNG arenot only more appropriate for nonrealistic images such as line drawings, butcan also achieve higher compression ratios if the images are relativelysimple, with large block lettering, solid blocks of color, and so on.
JPEG is also not appropriate for storing images in a master archive as itcauses an immediate degradation of the image relative to its uncompressedformat. Joyoshare media cutter 3 2 0 43. In addition, if the image is retrieved, modified, and then restoredas a JPEG, the degradation is likely to get worse.
[2.2] JPEG (1): LUMINANCE & CHROMINANCE IMAGE ENCODING / BLOCKS
* The JPEG committee was formed under the umbrella of the InternationalStandards Organization (ISO) in 1986, leading to the initial release of aspecification in 1991. The JPEG specification describes in general terms howto compress a digital image. It does not specify a particularimplementation.
In practice, JPEG is most often used to compress 24-bit color or 8-bitgrayscale images. The following discussion assumes that the JPEG coder iscompressing a 24-bit color bitmap image. Comments on how grayscale or lowcolor resolution images are handled are added at the end of the discussion.
This section and those following discuss the details of JPEG imagecompression. As it is very complicated, a summary is provided followingthese sections to review the main concepts.
* Each numeric value that describes the color of a pixel in a 24-bit colorimage actually breaks down into three values that define the exact color.There are two ways to define this set of three color values. Most of thecomputer literate are familiar with the 'RGB' color description scheme, whereeach pixel value is a set of by three numbers giving the red, green, and bluecolor value. For example, in RGB, each 24-bit value breaks down into three8-bit values, each giving the intensity of red, green, and blue in a scalefrom 0 to 255. Meta 1 9 – music tag editor pdf.
In the 'luminance-chrominance' scheme, used in traditional US analog colorTV, a pixel value is given by its grayscale brightness level, or 'luminance',and by a color value, or 'chrominance'.
Chrominance actually amounts to two values, one that describes the 'hue', orspecific color within a linear range of colors, and the other that describesthe 'saturation', or intensity of the color.
By the way, although chrominance is specified by two values, the actualvalues used aren't precisely the hue and the saturation. They're componentsof a two-dimensional vector, where the phase or angle of the vector gives thehue, and the magnitude of the vector gives the saturation. This indirectscheme is an artifact of the way the color signal is modulated in analogcolor TV broadcast. If this detail seems confusing, don't worry about it.You can just take it for granted that luminance is described by one value foreach pixel, and chrominance is described by a pair of values for each pixel.
Following TV usage, the luminance component is designated 'Y', and the twochrominance components are designated either as 'I' and 'Q', or 'U' and 'V',or 'Cr' and 'Cb'. For all I know these may actually represent differentformulas for chrominance, but if so it doesn't matter in this discussion.
The RGB and luminance-chrominance schemes are equivalent, and given one theother can be derived by some simple calculations. In principle, JPEGcompression can use either the RGB or luminance-chrominance scheme, but theluminance-chrominance scheme seems to be universal in practice, and thisdiscussion will assume its use.
* JPEG compression begins by converting the original two-dimensional imagedata array into three two-dimensional arrays, consisting of one array ofluminance data and two arrays of chrominance data. Each of these threearrays is then further divided up into a grid of two-dimensional arrays of 8rows of 8 pixels, giving 64 pixel values per block. These 8x8 'blocks' arethe target of JPEG encoding.
While computers display images using the RGB scheme, the pixel data isconverted to the luminance-chrominance scheme because it offers greaterpossibilities for compression. As mentioned earlier, this is because theluminance information contains most of the detail perceived by the human eye,while the overlying chrominance color information can be fuzzy withoutcausing any serious image degradation. The chrominance information reallyjust defines a tint overlaid on a grayscale image.
This means that JPEG doesn't necessarily need to keep all the chrominanceinformation, and the specification allows for a feature known as 'decimation'in which part of the chrominance information is simply thrown away.
For example, compression can be increased by only sampling every otherhorizontal pixel in a chrominance block, which cuts the number of chrominancebits in half. This is known as 'horizontal decimation', using a decimationfactor of 2, and results in one decimated 8x8 chrominance block for every twoluminance blocks.
Jpg Compress 2 2 07
Even more compression can be achieved by only sampling every other horizontaland vertical pixel in a chrominance block, which cuts the number ofchrominance bits to a fourth. This is known as 'horizontal and verticaldecimation' using a factor of 2, and results in one decimated 8x8 chrominanceblock for every four luminance blocks.
More sophisticated decimation algorithms, such as averaging, can be used, andit is possible to decimate by a factor of four. There is an odd nomenclaturefor designating decimated data. A block with no decimation is referred to as'4:4:4'; one with horizontal decimation only is referred to as '4:2:2'; andone with horizontal and vertical decimation is referred to as '4:2:0'.
[2.3] JPEG (1): SPECTRAL CONVERSION VIA DCT
* The first thing done to the 8x8 blocks in compression is to convert theirvalues into a 'spectrum'. To understand what this means and how it is done,for the moment arbitrarily assume that the block is from the luminancecomponent of the image. Actually, all three components are compressed in thesame way, but the luminance data provides the easiest example to visualize.
As you should know by now, the luminance data corresponds to a grayscaleversion of the original image. In more mathematical terms, the luminancedata defines a three-dimensional waveform or 'contour map' of the brightnessof the image in the block, with 'peaks' where the image is bright and'valleys' where it is dark.
The human eye can detect coarse details in the luminance image better than itcan detect fine details. This means that if the fine details aremathematically sorted out from a luminance block and thrown away to savestorage space, the image will (hopefully) still have an acceptableappearance.
This is the basic approach of the 'lossy' compression algorithm used by JPEG.The trick is figuring out how to sort out the fine details so they can bediscarded.
This is done through 'Fourier analysis'. According to Fourier analysis, anywaveform can be broken down into a set of pure sinusoidal waveforms ofvarying frequency and amplitude. This is done by a mathematical 'frequencydomain transform' operation, which converts the input waveform into a list ofamplitude values, or 'coefficients', for each pure sinusoidal value thatmakes up the original waveform. The list of coefficients is known as a'spectrum'.
In the current example, running the 8x8 block of luminance values through afrequency domain transform results in an 8x8 block of frequency coefficients.The low frequency coefficients correspond to the coarse details of the block,while the high frequency coefficients correspond to the fine details of theblock. In principle, high compression ratios can be obtained, at the expenseof fine details, by throwing away high frequency coefficients, with increasedcompression obtained by throwing away more coefficients.
In practice, JPEG doesn't actually throw the high frequency coefficientsaway. As will be explained momentarily, it just coarsens them, but the basicidea is the same.
* By the way, the usual way to think of a frequency domain transform is thatit converts a waveform that is a function of time into a set of amplitudesfor frequency components that can, in principle, be expressed in hertz. Forexample, in the frequency analysis of musical sounds, a complicated musicalsignal is broken down into a set of coefficients describing the simple soundwaves that make it up in terms of their amplitudes and frequencies.
However, in JPEG image compression the luminance values are just a set ofpixels that could represent anything. This means that the sinusoidal valuesin the spectrum obtained from the lumninance data are not expressed in hertz.They only have 'wavelengths' measured in terms of number of pixels andcorresponding array elements in the original luminance data, not time, andthe spectrum is only defined as as multiples of a starting (or 'fundamental',or 'base') frequency. These multiples are known as 'harmonics'.
Furthermore, the spectrum is simply a set of coefficient values giving theamplitudes of the harmonic components. The actual harmonics the coefficientsrefer to are defined by the array indexes.
If this sounds baffling, a simple example should help make it clear. Let'sconsider of converting a single row of a luminance block into a spectrumstored in an array with indexes from 0 to 7. The resulting data looks likethis:
- Array index 0: This is the 'zeroth harmonic' or 'constant component', discussed in a bit more detail below.
- Array index 1: Gives the amplitude coefficient of the base harmonic.
- Array index 2: Gives the coefficient for the second harmonic, with half the wavelength (twice the frequency) of the base harmonic.
- Array index 3: Gives the coefficient for the third harmonic, with 1/3rd the wavelength (3 times the frequency) of the base harmonic.
- Array index 4: Gives the coefficient for the fourth harmonic, with 1/4th the wavelength (4 times the frequency) of the base harmonic.
- Array index 5: Gives the coefficient for the fifth harmonic, with 1/5th the wavelength (5 times the frequency) of the base harmonic.
- Array index 6: Gives the coefficient for the sixth harmonic, with 1/6th the wavelength (6 times the frequency) of the base harmonic.
- Array index 7: Gives the coefficient for the seventh harmonic, with 1/7th the wavelength (7 times the frequency) of the base harmonic.
The element with index 0, referred to as the 'zeroth harmonic', doesn'trepresent a sinusoidal waveform. It represents a constant value, which is a'degenerate case' of a sinusoidal waveform. The zeroth harmonic is theaverage value of the waveform, and so is also called the 'constantcomponent'.
Of course, in the actual case of converting a luminance block to a spectrum,we actually end up with a two dimensional spectrum stored in an array with64 elements and indexes from (0,0) to (7,7). The element with the indexes(0,0) is, once more, the zeroth harmonic or constant component, and is aconstant value that gives the average brightness of the original luminanceblock.
All the other array elements give the coefficients of harmonics. The arrayelement with the index (0,1) gives the coefficient of the base harmonic thatonly varies in the horizontal direction, the element with (1,0) gives thecoefficient of the base harmonic that only varies in the vertical direction,and the element with index (1,1) gives the coefficient of the base harmonicthat varies in both directions.
Similarly, other indexes give the coefficients of appropriate combinationsof higher harmonics in either direction, finally ending with the arrayelement with index (7,7). This element gives the coefficient of the seventhharmonic in both directions.
* The best known frequency domain transform is the Fourier transform and itsvarious digital implementations, particularly the 'fast Fourier transform(FFT)'. However, JPEG compression uses a different but similar transformknown as the 'discrete cosine transform (DCT)'.
The FFT and the DCT give similar results, except for the way they handleendpoints. For a simplified example, consider an one-dimensional luminancewaveform made up of eight points that looks like this:Running this waveform through an FFT, eliminating some of the high frequencycomponents, and converting it back to a waveform again with an 'inverse FFT(IFFT)' gives something like:In comparison, running the waveform through a DCT, trimming off some of thehigh frequency components, and converting it back to a waveform again with an'inverse DCT (IDCT)' gives something closer to the original straight line:This example uses an eight-point one-dimensional waveform for simplicity, butthe same principle applies to the 8x8 two-dimensional DCT used in JPEGcompression.
* The precise details of the DCT are beyond the scope of this article, wouldmake the discussion far more complicated, and are more appropriate to adocument on signal processing. However, as mentioned earlier, the end resultof performing a DCT on an 8x8 block of luminance values is an 8x8 block ofharmonic coefficients for a set of implied two-dimensional sinusoidalwaveforms.
Incidentally, if you do a 'zoom' with a paint program to inspect the pixelsof a JPEG image stored with a high compression ratio, you can actually see'JPEG artifacts' that reflect these harmonics, such as checkerboard orstaggered-bar patterns. At high compression ratios, the high frequencyharmonic information has been degraded and no longer conceals the lowerharmonic patterns.
What is particularly fascinating is that for normal viewing the actual imagecan often look just fine even with all these artifacts, though they becomeincreasingly obvious as the quality factor is lowered and the compressionratio increased.
[2.4] JPEG (3): QUANTIZATION / ZIG-ZAG SCAN / LOSSLESS OUTPUT ENCODING
* By the way, the coefficient block that results from the DCT is equivalentto the original luminance block. No information has been thrown away. Ifyou run the coefficient block back through an IDCT, aside from normal smallcomputer calculation roundoff errors, you get the original luminance blockagain.
The next step in the compression process, known as 'quantization', is the onethat throws away information. Since the eye is less sensitive to highharmonics (fine details) in an image than low harmonics (coarse details), itis also less sensitive to alterations in the high harmonics, and thecoefficients of the high harmonics can be represented with fewer bits thanthe lower harmonics.
For example, suppose the values in the coefficient block are all 8 bitintegers, representing values from 0 to 255. For the lowest harmonics, wecan keep the values at 8 bits. For the highest harmonics, we could, forexample, convert the values to 4 bits, representing values from 0 to 15,saving half the storage for these coefficients. This is the 'coarsening'referred to earlier.
The conversion can be done by dividing the original 8-bit value by 16 andthrowing away the remainder, which a computer can do with a trivial shiftoperation. For example, if a high harmonic coefficient has a value of 137,dividing by 16 gives a value of 8. This will be restored to a value of 8 x16 = 128 by the uncompression process, which is a reasonable approximation.
Given 8-bit coefficient values, the 'quantization factor' can range from avalue of 1, meaning no loss, to 128, which compresses the coefficient valueto a single bit. The quantization factor is different for each of the 64coefficients in the block. JPEG uses a single 64-element table ofquantization factors, or 'Q table', to store the values for quantization,with the same table applied to all the blocks.
Jpg Compress 2 2 0 3
The quantization factors are not fixed. Adjusting the quality value forstoring a JPEG adjusts the quantization factors for the coefficient block,trading off compression ratio for image quality.
* Once a block has been converted to a spectrum and quantized, the JPEGcompression algorithm then takes the result and converts it into a onedimensional linear array, or 'vector', of 64 values, performing a 'zig-zag'scan by selecting the elements in the numerical order indicated by thenumbers in the grid below:This places the elements of the coefficient block in a reasonable order ofincreasing frequency. Since the higher frequencies are more likely to bezero after quantization, this tends to group zero values in the high end ofthe vector. The vector is then compressed using traditional losslesscompression algorithms.
Actually, just to make things confusing again, the first element of thevector, which stores the quantized coefficient for the constant component ofthe luminance block, is compressed differently from the other 63 quantizedcoefficients, and after that they both go through a second stage ofcompression. JPEG seems to leave no stone unturned in its search for highcompression ratios.
The idea of compressing the first element separately is particularly bafflingat first sight, since there's only one value and that wouldn't seem to offermuch room for compression. The trick is that the compression is performedbetween the DC terms of consecutive blocks, using 'delta modulation'.
Since the DC term doesn't change much from luminance block to neighboringluminance block, then the difference between the values of the coefficientsof the DC term for the two blocks is usually small. In delta modulation,only the difference between the two coefficients is stored. Of course the DCterm coefficient for the very first block is compared to a value of 0.
The other 63 values in the vector are compressed as a group, not compressedrelative to vectors derived from neighboring blocks. The compression isperformed with RLE, which takes advantage of the clustering of zero values bythe zig-zag scan. Once the quantized coefficients have gone through theirfirst stage of lossless encoding, they go through the second stage ofcompression using Huffman coding.
JPEG permits the use of a default Huffman table, or custom Huffman tablesderived specifically from the data in the image being compressed. Use of adefault Huffman table will very likely give poorer compression than use ofcustom Huffman tables, but the default tables won't have to be stored withthe rest of the data, so there's a trade-off.
* Although this discussion has focused on compressing the array of luminancevalues, the same process is used to compress the two arrays of chrominancevalues as well. The only differences are that chrominance data may bedecimated, as discussed earlier, and the chrominance values may have theirown Q-tables.
In any case, decompressing the encoded image uses exactly the reverse stepsof the process described above: Huffman decoding; RLE and delta-modulationdecoding; unpacking from a vector format to a block format; dequantizing;IDCT; reassembly of blocks into a full image component; and reassembly of theimage components into the image.
* Of course, compressing a grayscale image is equivalent to compressing justthe luminance component. However, it appears that JPEG cannot compress acolor image with 8-bit color resolution, at least not as such. As best as Ican figure out, this is because JPEG can only compress a color bitmap that isa 'true color' image, while a color bitmap with 8-bit color resolution is'color mapped'.
In a true color image, such as a bitmap with 24-bit color resolution, thevalue for each pixel actually gives the pixel color as an RGB value. In acolor-mapped image, the value for each pixel is an index into a table of 256RGB values, known unsurprisingly as a 'color map'.
The RGB values in the color map may be 12 or more bits of color resolution.This allows an 8 bit color bitmap to have access to a wide range of colors,but the trick is that it can only use 256 different colors from that rangeat one time. The selection of 256 colors is known as a 'palette'. An imagefile for a color mapped image consists of a grid of indexes, one for eachpixel, plus a table of color map values defining the palette.
This is why strange things happen when cutting and pasting 8-bit color imagesin paint program. If you have two different 8-bit color images, each willusually have a different palette. If you cut an item from one and paste itinto the other, the colors in the pasted item will often look very strange,since the image into which it is pasted has a different palette and theindexes for the pasted element are now pointing to the wrong colors.
Naturally, this doesn't happen with 24-bit color or other true color images,since they don't use a color map. You can cut and paste between two imagesand the results look fine.
Anyway, JPEG compression requires that the bitmap image provide RGB values soit can convert them into luminance and chrominance components. The pixelvalues for an 8-bit color bitmap aren't RGB values, they're indexes. TheJPEG coder will use the indexes and the color map data provided with theimage to produce a true color image, and then compress it. While reducingcolor image resolution from 24 bits to 8 bits will reduce file size by afactor of three for uncompressed images and will have at least that mucheffect on images compressed with typical lossless methods, it has no effectwith JPEG since the 8 bits get converted back into 24 and all you've done islose colors in your image.
[2.5] JPEG SUMMARY & STREAM FORMAT
* JPEG compression is confusing, as even JPEG advocates will , so a summarymay help make matters clearer. JPEG compression follows these steps:
- Separate a color image array into one luminance array and two chrominance arrays. The chrominance arrays may be decimated to achieve higher compression ratios. A grayscale image is equivalent to a luminance array without the two chrominance arrays.
- Break the arrays into 8x8 blocks.
- Perform a discrete cosine transform (DCT) on the blocks to obtain blocks of corresponding harmonic coefficients.
- Quantize the values in each coefficient block using a quantization table with scaling values for each element in the block.
- Convert the quantized coefficient block into a 64-element linear array using 'zig-zag scan'.
- Compress the first (constant) element in the linear array by performing delta modulation between arrays.
- Compress the other 63 elements of a single block using lossless run length encoding (RLE).
- Perform Huffman coding on the all the results.
The result of the compression is a stream of compressed data, which could bestored as a file or sent over a communications link. The structure of theJPEG stream follows directly from the compression algorithm.
The stream starts with a 'start of image' flag and ends with an 'end ofimage' flag. The contents between these flags define a 'frame', which givesthe entire image, which is structured as follows:
- The frame starts with miscellaneous tables including custom Huffman tables, quantization tables, and so on.
- The tables are followed by a header giving the bitmap image size, width, depth, and so on.
- The header is followed in turn by a series of 'scans', each giving a component of the image. Each scan consists of tables, followed by a descriptive header, and then 'segments', which are arrays of encoded 8x8 blocks.
[2.6] JPEG VARIANTS / JPEG-2000 / JBIG
* There are a number of variations on the basic JPEG compression scheme. Themost important is 'progressive JPEG', which is basically the same as standardJPEG except that it allows an image to be progressively displayed in greaterdetail as it is downloaded. There are a number of approaches to progressiveencoding, but one of the most straightforward is to send the constantcomponents of the blocks first, then keep sending higher harmonics, makingthe image increasingly clear.
There are 'lossless JPEG' specifications as well, which as their nameindicates, compress without throwing any detail away. Unsurprisingly, theydon't use the same compression techniques as lossy JPEG, and as they are notin widespread use they will not be discussed further here.
There is also a 'hierarchical' JPEG mode, which is used for encoding imagesfor presentation on a smaller display, and 'Motion JPEG', which is used forencoding video by using JPEG compression on individual frames. Neither ofthese appear to be in much use. Motion JPEG is clearly inferior to thepopular MPEG video compression spec in terms of compression ratios. MPEG,discussed in the next chapter, has some similarities to JPEG but involves useof delta modulation, generally sending changes in images from video frame tovideo frame rather than full frames, allowing it to obtain much greatercompression.
Various different implementations of Motion JPEG appear to be in some use invideo editing systems, since the delta modulation scheme used by MPEG tendsto make video splicing a little more troublesome.
* JPEG compression is based on the DCT, a form of sinusoidal transform.There is another class of transforms, based on functions known as 'wavelets',that instead of sinusoidal functions use sets of functions that resemblejagged pulses. They can in principle represent a time domain waveform withfewer coefficients than sinusoidal functions.
A new version of JPEG, named 'JPEG 2000', that replaces the DCT with awavelet transform, has now been introduced. The ISO JPEG 2000 committeeofficially released the specification in 2001 under the designation of 'ISO15444'. Software supporting the new image format is now gradually becomingavailable, though at last notice it wasn't supported by Web browsers, whichwould clearly signal its coming-of-age. However, some organizations' havemade noises about patent issues on the original JPEG specification. Thesepatents don't apply to JPEG 2000 and so such actions may drive introductionto the new specification.
As with traditional JPEG, JPEG 2000 begins by converting an RGB image into aluminance-chrominance image, and the chrominance information can be decimatedif desired. The resulting data is then split into subarrays or 'tiles',which are wavelet-transformed to the desired number of wavelet terms. Thisdata in turn is 'sliced and diced' in a complicated fashion and put throughthree levels of arithmetic coding to produce 'packets' that make up JPEG 2000stream. The packets are organized in such a way that a substream could beselected to give a smaller 'thumbnail' image, or a reduced-quality image, ora monochrome image, or whatever.
JPEG 2000 is estimated to give about 20% better compression than traditionalJPEG. Comparisons of the same image stored in JPEG and JPEG 2000 format withquality settings to give the same file size show a startling improvement inimage quality, with most of the notorious ugly JPEG artifacts simplydisappearing in JPEG 2000.
An enhancement known as 'mixed-raster content' is under considerationfor JPEG-2000, in which a coder will switch compression algorithms to, forexample, allow crisper compression of blocks of text, which tend to have ablurry appearance in the current JPEG implementation. Another enhancement isbuilt-in support for Motion JPEG, allowing a JPEG image to incorporate'metadata' that describes the order and speed of frame presentation.
Jpg Compress 2 2 0 1
* JPEG is a grossly inefficient scheme for compressing black and white, or'bilevel', images, since they have to be converted to 24 bits, and so adifferent specification, known as 'JBIG', has been devised to address thatissue. It has little do to with JPEG in terms of implementation, and isreally a complementary specification rather than a variation on JPEG.Details are beyond the scope of this document.
[2.7] VECTOR & FRACTAL COMPRESSION
* Some other compression schemes, such as vector quantization and fractalcompression, have some interest value, though they are not in common use.
For a conceptual explanation of vector quantization, suppose a black andwhite image is broken down into 8x8 blocks as in JPEG quantization. Supposealso that an encoder, and its corresponding decoder, have a 'library' of 256or more blocks that approximate the actual pattern in any arbitrary imageblock. It would be possible to obtain an 8:1 compression ratio by matchingeach block in the image with a block in the library, and just sending a codebyte designating which block in the library matches the image block.Compression could be increased by using some type of lossless compression onthe coded bytes.
* Fractal compression is based on transform mathematics, but the approach isvery different from that of conventional frequency analysis.
Compress Jpg File online, free
Fractals are geometric figures based on recursive expansion of a basicgeometric figure. For example, the Sierpinski Triangle is a fractal patternthat consists of a small triangle built up hierarchically as follows:Figure 1 on the left consists of a basic triangle. Figure 2 is a trianglebuilt from three basic triangles. Figure 3 is built from three of the secondfigures, or nine basic triangles, while figure 4 is built from three of thethird figure, or nine of the second figure, or 27 basic triangles.
This is a very simple fractal and it is hard to see what it has to do withimage compression, but a more sophisticated fractal can be used to build arealistic image of a fern leaf, where the fronds of the leaf look like theleaf itself, and on on down to the limit of graphics resolution. Fractalsare said to be 'self similar', meaning that if you look at a small part ofthe image, such as one of the fronds of the fern leaf, it looks like theentire image of the fern leaf.
Fractal patterns are well suited for representation of hierarchical objectslike trees, or objects like clouds, mountains, or coastlines that reveal alower level of 'self similar' detail at closer focus. Fractals have oftenbeen used in computer graphics videos, as they tend to provide pleasing and,in some cases, highly lifelike images. The well-known 'Genesis Torpedo'computer video segment from the movie STAR TREK 2: THE WRATH OF KAHN is oneof the best known examples of fractal computer graphics, with a wave of firesweeping over a barren planet that then becomes covered with life.
Given that fractal patterns can be used to generate images of objects, it'snot too big of a jump to suspect that an arbitrary image could be broken downinto a series of fractal patterns. This opens the possibility of extremelyhigh image compression ratios. The image would be analyzed to determine thefractal patterns that make it up and transformed into relatively small andcompact sets of parameters that define the proper fractal algorithms, Theparameters could then be further compressed with some lossless compressionalgorithm, in principle resulting in a very compact graphics file.
* Fractal compression is not a new idea. It goes back to the late 1980s andan organization named Iterated Systems, which was founded by severalmathematicians from the Georgia Institute of Technology. The scheme isconfronted by two obstacles: first, figuring out transform operations thatcan convert an arbitrary image element into a fractal, and second, performingthese operations in a reasonable amount of time, as they tend to be verycomputation-intensive.
The first problem, converting an image into a fractal algorithm, turned outto be particularly difficult, and in fact Iterated Systems was accused offraud by some critics. Using a fractal algorithm to produce a pretty fernleaf is one thing, but taking a real-life fern leaf with its manyimperfections and converting it to a fractal algorithm is another thingentirely, and although there are many objects in the real world that havefractal properties, many of them don't.
Critics referred to the original scheme for transforming an image into afractal as the 'graduate student algorithm'. It involved locking a graduatestudent into a room with a graphics workstation until he or she had come upwith the appropriate fractal algorithm to recreate the image. Automatedmethods have been devised, but the critics are still suspicious, though ithas to be noted that data compression hacks tend to be critical andquarrelsome in general and it is difficult to know how seriously to take themsometimes.
Fractal compression advocates claim the technique can provide 'resolutionenhancement', meaning that if an image compressed with fractal encoding isenlarged, it's still detailed. This is a bit slippery because this onlyreally applies to elements that have a fractal appearance where the conceptof self-similarity applies. That is, if you have an image of a cloud, whichis a fractal form, and enlarge it tremendously, it still looks like a prettygood image of a cloud.
However, all that additional detail is a fabrication, created by the fractalalgorithm. If there were an original image available at the same scale, thefine details would be different. The resolution enhancement breaks downseriously for elements that do not have a fractal appearance. As the sayinggoes, you really can't get something for nothing.
All the controversy aside, fractal compression is typically verytime-consuming, though decompression is relatively straightforward as itsimply requires chugging through the fractal algorithms, not determining whatthey are in the first place. In practice, so far fractal compression has notprovided significantly higher compression ratios than, say, JPEG.
Fractal compression is a very interesting concept, but its current status isuncertain. Fractals are not as sexy a concept now as they were in the 1980s,when everyone overdosed on psychedelic Mandelbrot set pictures. Whatever itsfacts of the case, I'm not inclined to hold my breath waiting for fractalcompression to take over the world.