IMWRITE

NAME
SYNOPSIS
PARAMETERS
DESCRIPTION
EXAMPLE
FILE FORMATS
REMARKS
BUGS AND SHORTCOMINGS
AUTHORS
AVAILABILITY
SEE ALSO

NAME

imwrite - writes to an image file in ANY format

SYNOPSIS

imwrite(Image, filename, [opt_args])
imwrite(Index, Map, filename, [opt_args])

PARAMETERS

filename
a string, the image filename to be created. The extension determines the type of the image.
Image
For truecolor images, this is a MxNx3 hypermatrix in 0-1 range; For binary images or intensity grayscale images, it is a MxNx1 matrix in 0-1 range.
Index
MxN matrix containing the indexes to the image colormap (for indexed images). Indices start at 1.
Map
Mx3 matrix containing the image colormap (for indexed images). Entries range from 0 to 1
[opt_args]
This is a sequence of statements key1=value1, key2=value2,... where key1, key2,... can be one of the following:
quality
sets the quality level for some formats of images that accept this parameter, like JPEG. Ranges from 1 to 100 (default 75).
In the future, other options may be added, such as dithering and compression type.

DESCRIPTION

imwrite creates BMP, GIF, JPEG, PNG, PCX, TIFF, XPM, and even more types of image files from Scilab elements. The format of the file is inferred from the extension in the filename parameter.
imwrite(Img, filename) creates an image filename in disk, from Img matrix. For truecolor images, Img is a MxNx3 hypermatrix, so for example Img(:,:,1) stands for the red channel. For binary images or intensity grayscale images, Img is a MxNx1 matrix.
imwrite(Index, Map, filename) does the same work, but from Index (MxN) and Map (Mx3) matrices. Grayscale and Paletted images are written in this way.

EXAMPLE

a=rand(100,150);    // create a random image
xbasc();
imshow(a);
imwrite(a,'SIPtmp.jpg');
xbasc();
imshow('SIPtmp.jpg');
// now try viewing this image with an ordinary viewer to see
// how it really worked!

FILE FORMATS

SIP should work with the following formats, but there is no waranty (unless you pay something :-). Please contact us in case of any problems.
Name Mode Description o 8BIM *rw- Photoshop resource format o AFM *r-- TrueType font o APP1 *rw- Photoshop resource format o ART *r-- PF1: 1st Publisher o AVI *r-- Audio/Visual Interleaved o AVS *rw+ AVS X image o BIE *rw- Joint Bi-level Image experts Group interchange format o BMP *rw+ Microsoft Windows bitmap image o CAPTION *r+ Caption (requires separate size info) o CMYK *rw- Raw cyan, magenta, yellow, and black samples (8 or 16 bits, depending on the image depth) o CMYKA *rw- Raw cyan, magenta, yellow, black, and matte samples (8 or 16 bits, depending on the image depth) o CUT *r-- DR Halo o DCM *r-- Digital Imaging and Communications in Medicine image o DCX *rw+ ZSoft IBM PC multi-page Paintbrush o DIB *rw+ Microsoft Windows bitmap image o DPS *r-- Display PostScript o DPX *r-- Digital Moving Picture Exchange o EPDF *rw- Encapsulated Portable Document Format o EPI *rw- Adobe Encapsulated PostScript Interchange format o EPS *rw- Adobe Encapsulated PostScript o EPS2 *-w- Adobe Level II Encapsulated PostScript o EPS3 *-w- Adobe Level III Encapsulated PostScript o EPSF *rw- Adobe Encapsulated PostScript o EPSI *rw- Adobe Encapsulated PostScript Interchange format o EPT *rw- Adobe Encapsulated PostScript with TIFF preview o FAX *rw+ Group 3 FAX o FILE *r-- Uniform Resource Locator o FITS *rw- Flexible Image Transport System o FPX *rw- FlashPix Format o FTP *r-- Uniform Resource Locator o G3 *rw- Group 3 FAX o GIF *rw+ CompuServe graphics interchange format o GIF87 *rw- CompuServe graphics interchange format (version 87a) o GRADIENT *r-- Gradual passing from one shade to another o GRANITE *r-- Granite texture o GRAY *rw+ Raw gray samples (8 or 16 bits, depending on the image depth) o H *rw- Internal format o HDF -rw+ Hierarchical Data Format o HISTOGRAM *-w- Histogram of the image o HTM *-w- Hypertext Markup Language and a client-side image map o HTML *-w- Hypertext Markup Language and a client-side image map o HTTP *r-- Uniform Resource Locator o ICB *rw+ Truevision Targa image o ICM *rw- ICC Color Profile o ICO *r-- Microsoft icon o ICON *r-- Microsoft icon o IMPLICIT *--- o IPTC *rw- IPTC Newsphoto o JBG *rw+ Joint Bi-level Image experts Group interchange format o JBIG *rw+ Joint Bi-level Image experts Group interchange format o JP2 *rw- JPEG-2000 JP2 File Format Syntax o JPC *rw- JPEG-2000 Code Stream Syntax o JPEG *rw- Joint Photographic Experts Group JFIF format o JPG *rw- Joint Photographic Experts Group JFIF format o LABEL *r-- Text image format o LOGO *rw- ImageMagick Logo o M2V *rw+ MPEG-2 Video Stream o MAP *rw- Colormap intensities (8 or 16 bits, depending on the image depth) and indices (8 or 16 bits, depending on whether colors exceeds 256). o MAT *-w+ MATLAB image format o MATTE *-w+ MATTE format o MIFF *rw+ Magick image format o MNG *rw+ Multiple-image Network Graphics o MONO *rw- Bi-level bitmap in least-significant- -byte-first order o MPC -rw- Magick Persistent Cache image format o MPEG *rw+ MPEG-1 Video Stream o MPG *rw+ MPEG-1 Video Stream o MPR *r-- Magick Persistent Registry o MSL *r-- Magick Scripting Language o MTV *rw+ MTV Raytracing image format o MVG *rw- Magick Vector Graphics o NETSCAPE *r-- Netscape 216 color cube o NULL *r-- Constant image of uniform color o OTB *rw- On-the-air bitmap o P7 *rw+ Xv thumbnail format o PAL *rw- 16bit/pixel interleaved YUV o PALM *rw- Palm Pixmap format o PBM *rw+ Portable bitmap format (black and white) o PCD *rw- Photo CD o PCDS *rw- Photo CD o PCL *-w- Page Control Language o PCT *rw- Apple Macintosh QuickDraw/PICT o PCX *rw- ZSoft IBM PC Paintbrush o PDB *r-- Pilot Image Format o PDF *rw+ Portable Document Format o PFA *r-- TrueType font o PFB *r-- TrueType font o PFM *r-- TrueType font o PGM *rw+ Portable graymap format (gray scale) o PICON *rw- Personal Icon o PICT *rw- Apple Macintosh QuickDraw/PICT o PIX *r-- Alias/Wavefront RLE image format o PLASMA *r-- Plasma fractal image o PM *rw- X Windows system pixmap (color) o PNG *rw- Portable Network Graphics o PNM *rw+ Portable anymap o PPM *rw+ Portable pixmap format (color) o PREVIEW *-w- Show a preview an image enhancement, effect, or f/x o PS *rw+ Adobe PostScript o PS2 *-w+ Adobe Level II PostScript o PS3 *-w+ Adobe Level III PostScript o PSD *rw- Adobe Photoshop bitmap o PTIF *rw- Pyramid encoded TIFF o PWP *r-- Seattle Film Works o RAS *rw+ SUN Rasterfile o RGB *rw+ Raw red, green, and blue samples (8 or 16 bits, depending on the image depth) o RGBA *rw+ Raw red, green, blue, and matte samples (8 or 16 bits, depending on the image depth) o RLA *r-- Alias/Wavefront image o RLE *r-- Utah Run length encoded image o ROSE *rw- 70x46 Truecolor test image o SCT *r-- Scitex HandShake o SFW *r-- Seattle Film Works o SGI *rw+ Irix RGB image o SHTML *-w- Hypertext Markup Language and a client-side image map o STEGANO *r-- Steganographic image o SUN *rw+ SUN Rasterfile o SVG *rw+ Scalable Vector Gaphics o TEXT *rw+ Raw text o TGA *rw+ Truevision Targa image o TIF *rw+ Tagged Image File Format o TIFF *rw+ Tagged Image File Format o TILE *r-- Tile image with a texture o TIM *r-- PSX TIM o TTF *r-- TrueType font o TXT *rw+ Raw text o UIL *-w- X-Motif UIL table o UYVY *rw- 16bit/pixel interleaved YUV o VDA *rw+ Truevision Targa image o VICAR *rw- VICAR rasterfile format o VID *rw+ Visual Image Directory o VIFF *rw+ Khoros Visualization image o VST *rw+ Truevision Targa image o WBMP *rw- Wireless Bitmap (level 0) image o WMF *r-- Windows Metafile o WPG *r-- Word Perfect Graphics o X *rw- X Image o XBM *rw- X Windows system bitmap (black and white) o XC *r-- Constant image uniform color o XCF *r-- GIMP image o XML *r-- Scalable Vector Gaphics o XPM *rw- X Windows system pixmap (color) o XV *rw+ Khoros Visualization image o XWD *rw- X Windows system window dump (color) o YUV *rw- CCIR 601 4:1:1
Modes: * Native blob support (no call to external utility) r Read w Write + Multi-image

REMARKS

In writing a binary image, there is NO MORE NEED to multiply it by 65535.
The file created by imwrite is not necessarily indexed or truecolor. Commands of the form imwrite(I,M,filename) have a greater chance of creating an indexed image, and imwrite(RGB,filename) have a good chance of creating a truecolor image. However, the final result depends on the characteristics of the image format. For example, JPEG images are always truecolor or grayscale. Typing imwrite(Index,Map,'foo.jpg') will necessarily create a truecolor image. But imwrite(Index,Map,'foo.gif') will certainly create an indexed image.

BUGS AND SHORTCOMINGS

Images are stored in double precision matrices. Hopefully, the next release will make use of integer types.

AUTHORS

Ricardo Fabbri <rfabbri@if.sc.usp.br>

AVAILABILITY

The latest version of the Scilab Image Processing toolbox can be found at
http://siptoolbox.sourceforge.net

SEE ALSO

imread, imfinfo, imshow