>> help imwrite IMWRITE Write image to graphics file. IMWRITE(A,FILENAME,FMT) writes the image A to FILENAME. FILENAME is a string that specifies the name of the output file, and FMT is a string the specifies the format of the file. A can be either a grayscale image (M-by-N) or a truecolor image (M-by-N-by-3). The possible values for FMT include: 'tif' or 'tiff' Tagged Image File Format (TIFF) 'jpg' or 'jpeg' Joint Photographic Experts Group (JPEG) 'bmp' Windows Bitmap (BMP) 'png' Portable Network Graphics (PNG) 'hdf' Hierarchical Data Format (HDF) 'pcx' Windows Paintbrush (PCX) 'xwd' X Window Dump (XWD) IMWRITE(X,MAP,FILENAME,FMT) writes the indexed image in X, and its associated colormap MAP, to FILENAME. If X is of class uint8 or uint16, IMWRITE writes the actual values in the array to the file. If X is of class double, IMWRITE offsets the values in the array before writing, using uint8(X-1). MAP must be a valid MATLAB colormap. Note that most image file formats do not support colormaps with more than 256 entries. IMWRITE(...,FILENAME) writes the image to FILENAME, inferring the format to use from the filename's extension. The extension must be one of the legal values for FMT. IMWRITE(...,PARAM1,VAL1,PARAM2,VAL2,...) specifies parameters that control various characteristics of the output file. Parameters are currently supported for HDF, JPEG, TIFF, and PNG files. Data types ---------- Most of the supported image file formats store uint8 data. PNG and TIFF additionally support uint16 data. For grayscale and RGB images, if the data array is double, the assumed dynamic range is [0,1]. The data array is automatically scaled by 255 before being written out as uint8. If the data array is uint8 or uint16 (PNG and TIFF only), then it is written out without scaling as uint8 or uint16, respectively. NOTE: If a logical double or uint8 is written to a PNG or TIFF file, it is assumed to be a binary image and will be written with a bitdepth of 1. For indexed images, if the index array is double, then the indices are first converted to zero-based indices by subtracting 1 from each element, and then they are written out as uint8. If the index array is uint8 or uint16 (PNG and TIFF only), then it is written out without modification as uint8 or uint16, respectively. When writing PNG files, you can override this behavior with the 'BitDepth' parameter; see below for details. HDF-specific parameters ----------------------- 'Compression' One of these strings: 'none' (the default), 'rle' (only valid for grayscale and indexed images), 'jpeg' (only valid for grayscale and RGB images) 'Quality' A number between 0 and 100; parameter applies only if 'Compression' is 'jpeg'; higher numbers mean quality is better (less image degradation due to compression), but the resulting file size is larger 'WriteMode' One of these strings: 'overwrite' (the default) or 'append' JPEG parameters and values include: 'Quality' A number between 0 and 100; higher numbers mean quality is better (less image degradation due to compression), but the resulting file size is larger TIFF-specific parameters ------------------------ 'Compression' One of these strings: 'none', 'packbits' (default for nonbinary images), 'ccitt' (default for binary images); 'ccitt' is valid for binary images only 'Description' Any string; fills in the ImageDescription field returned by IMFINFO 'Resolution' A two-element vector containing the XResolution and YResolution, or a scalar indicating both resolutions; the default value is 72 PNG-specific parameters ----------------------- 'Author' A string 'Description' A string 'Copyright' A string 'CreationTime' A string 'Software' A string 'Disclaimer' A string 'Warning' A string 'Source' A string 'Comment' A string 'InterlaceType' Either 'none' or 'adam7' 'BitDepth' A scalar value indicating desired bitdepth; for grayscale images this can be 1, 2, 4, 8, or 16; for grayscale images with an alpha channel this can be 8 or 16; for indexed images this can be 1, 2, 4, or 8; for truecolor images with or without an alpha channel this can be 8 or 16 'Transparency' This value is used to indicate transparency information when no alpha channel is used. For indexed images: a Q-element vector in the range [0,1]; Q is no larger than the colormap length; each value indicates the transparency associated with the corresponding colormap entry For grayscale images: a scalar in the range [0,1]; the value indicates the grayscale color to be considered transparent For truecolor images: a 3-element vector in the range [0,1]; the value indicates the truecolor color to be considered transparent You cannot specify 'Transparency' and 'Alpha' at the same time. 'Background' The value specifies background color to be used when compositing transparent pixels. For indexed images: an integer in the range [1,P], where P is the colormap length For grayscale images: a scalar in the range [0,1] For truecolor images: a 3-element vector in the range [0,1] 'Gamma' A nonnegative scalar indicating the file gamma 'Chromaticities' An 8-element vector [wx wy rx ry gx gy bx by] that specifies the reference white point and the primary chromaticities 'XResolution' A scalar indicating the number of pixels/unit in the horizontal direction 'YResolution' A scalar indicating the number of pixels/unit in the vertical direction 'ResolutionUnit' Either 'unknown' or 'meter' 'Alpha' A matrix specifying the transparency of each pixel individually; the row and column dimensions must be the same as the data array; may be uint8, uint16, or double, in which case the values should be in the range [0,1] 'SignificantBits' A scalar or vector indicating how many bits in the data array should be regarded as significant; values must be in the range [1,bitdepth] For indexed images: a 3-element vector For grayscale images: a scalar For grayscale images with an alpha channel: a 2-element vector For truecolor images: a 3-element vector For truecolor images with an alpha channel: a 4-element vector In addition to these PNG parameters, you can use any parameter name that satisfies the PNG specification for keywords: only printable characters, 80 characters or fewer, and no leading or trailing spaces. The value corresponding to these user-specified parameters must be a string that contains no control characters except for linefeed. Table: summary of supported image types --------------------------------------- BMP 8-bit and 24-bit uncompressed images TIFF Baseline TIFF images, including 1-bit, 8-bit, and 24-bit uncompressed images; 1-bit, 8-bit, and 24-bit images with packbits compression; 1-bit images with CCITT compression JPEG Baseline JPEG images PNG 1-bit, 2-bit, 4-bit, 8-bit, and 16-bit grayscale images; 8-bit and 16-bit grayscale images with alpha channels; 1-bit, 2-bit, 4-bit, and 8-bit indexed images; 24-bit and 48-bit truecolor images; 24-bit and 48-bit truecolor images with alpha channels HDF 8-bit raster image datasets, with or without associated colormap; 24-bit raster image datasets; uncompressed or with RLE or JPEG compression PCX 8-bit images XWD 8-bit ZPixmaps See also IMFINFO, IMREAD, FWRITE. >> diary off