The WRITE_JPEG procedure writes compressed images to files. JPEG (Joint Photographic Experts Group) is a standardized compression method for full-color and gray-scale images. This procedure is based in part on the work of the "Independent JPEG Group".
As the Independent JPEG Group states, JPEG is intended for "real-world" scenes (such as digitized photographs). Line art, such as drawings or IDL plots, and other "unrealistic" images are not its strong suit. Note also that JPEG is a "lossy" compression scheme. That is, the output image is not identical to the input image. Hence you must not use JPEG if you have to have identical output bits. However, on typical images of real-world scenes, very good compression levels can be obtained with no visible change, and amazingly high compression levels are possible if you can tolerate a low-quality image. You can trade off output image quality against compressed file size by adjusting a compression parameter. Files are encoded in JFIF, the JPEG File Interchange Format (however, such files are usually simply called "JPEG" files).
If you need to store images in a compressed format that is not lossy, consider using the WRITE_GIF procedure. This procedure writes 8-bit (256 color) images in the Graphics Interchange Format. To store 8-bit or 24-bit images without compression, consider using the WRITE_BMP (for Microsoft Bitmap format files) or WRITE_TIFF (to write Tagged Image Format Files) procedures.
For a short technical introduction to the JPEG compression algorithm, see: Wallace, Gregory K. "The JPEG Still Picture Compression Standard", Communications of the ACM , April 1991 (vol. 34, no. 4), pp. 30-44.
To read JPEG files, use the READ_JPEG procedure (page READ_JPEG ).
NOTE: All JPEG files consist of byte data. Input data is converted to bytes before being written to a JPEG file.
JPEG/JFIF images are normally written in top-to-bottom order. If the image array is in the standard IDL order (i.e., from bottom-to-top) set ORDER to 0, its default value. If the image array is in top-to-bottom order, ORDER must be set to 1.
Set this keyword to write the image as a series of scans of increasing quality. When used with a slow communications link, a decoder can generate a low-quality image very quickly, and then improve its quality as more scans are received.
This keyword specifies the quality index, in the range of 0 ("terrible") to 100 ("excellent") for the JPEG file. The default value is 75, to obtain "very good" quality. Lower values of QUALITY produce higher compression ratios and smaller files.
This keyword specifies the index, starting at 1, of the dimension over which the color is interleaved. For example, for an image that is pixel interleaved and has dimensions of (3, m , n ), set TRUE to 1. Specify 2 for row-interleaved images ( m , 3, n ); and 3 for band-interleaved images ( m , n , 3). If TRUE is not set, the image is assumed to have no interleaving (it is not a true-color image).
This keyword designates the logical unit number of an already open file to receive the output, allowing multiple JFIF images per file or the embedding of JFIF images in other data files. If this keyword is used, Filename should not be specified. When using VMS, open the file with the /STREAM keyword.
Write the image contained in the array A, using JPEG compression with a quality index of 25. The image is stored in bottom-to-top order:
WRITE_JPEG, 'test.dat', a, QUALITY=25
Write a true-color image to a JPEG file. The image is contained in the band-interleaved array A with dimensions ( m , n ,3). Assume it is stored in top-to-bottom order: