In addition to the functions for reading and writing bitmap files described above, Mathcad Professional includes an assortment of more specialized functions for reading images or image components, including functions for reading images in GIF, JPG, and TGA formats. Your choice of which function to use will depend on:
• Whether you want to create a Mathcad matrix in which the image is separated into: red, green, and blue (RGB); hue, lightness, and saturation (HLS); or hue, saturation, and value (HSV) components.
• Whether you want to read in the entire image or just one component (for example, only the red values) of the image.
The functions used to read images work in exactly the same way as READBMP described in the previous section, but each recognizes images in the following formats: BMP, GIF, JPG, and TGA. Each function a string expression as described in “Arguments to file access functions” on page 448. The string can correspond to either:
• the name of an image (BMP, GIF, JPG, or TGA format) file in the working directory of the Mathcad worksheet you’re currently working on; or
• a full or relative path to an image file located elsewhere on a local or network file system.
Each function returns a matrix of numbers used to represent the image In addition to the WRITEBMP and WRlTERGB functions described in the previous section, Mathcad Professional has functions for creating color BMP files out of matrices in which the image is stored in HLS or HSV format
Like WRlTEBMP and WRITERGB, these functions each take a string expression as described in “Arguments to file access functions” on page 448. The string can correspond to either:
• the name of a bitmap (BMP format) file in the working directory of the Mathcad worksheet you’re currently working on; or
• a full or relative path to a bitmap file located elsewhere on a local or network file system.
To use these functions, you write an assignment expression with the left-hand side containing the call to the WRITE_HLS or WRITE_HSV function and the right-hand side containing a matrix expression. For example, to create the 24-bit color image file process .bmp in the current directory from matrices H, L, and S corresponding to the hue, light, and saturation components of the image, enter: