ImageTools

 read an image from a file or URL

 Calling Sequence Read( file, img, opts ) Read( url, img, opts )

Parameters

 file - string; the pathname of the image file to read url - string; URL address of an image file to read img - (optional) Image; rtable to read image into opts - (optional) equation(s) of the form option = value; specify options for the Read command

Options

 • format = BMP, JPEG, PNG, or TIFF
 Specifies the image format. It must be one of the values in ImageTools[Formats]. If not specified, the Read command guesses the format from the extension of file.
 • output = imgo

Specifies a data structure into which the output is written; imgo must be of type Image. The size must match that of the input. If imgo is one layer, then the image is converted to a grayscale, as needed. If imgo has four layers and the image file does not, then the fourth layer is set to all zeros. The default is NULL.

 • datatype = float[8]
 • datatype = integer[1]

Specifies if the created Image should use one 8-byte floating point value (the default) or one 1-byte integer value per channel per pixel. The former result in less degredation when manipulating the image (scaling, convolution, gamma adjustment, and so on), but requires 8 times the memory of the latter.

Description

 • The Read command returns an Image read from an image file in one of the supported formats. After completing the read, the file is closed.
 • The Read command can read most variations of the supported formats. Those that are not grayscale, RGB, or RGBA, such as YCbCr or color-mapped images, are converted to one of the supported formats while being read.
 • The file parameter is the name of the file and it must be a Maple string. If the format option is not provided, the file format is determined from the extension of the file name. For example, the string image.jpg is read as a JPEG file.
 • The optional img parameter is a data structure into which the image is written.  It must be of type Image and have the proper dimensions and layers for the image. Using the img parameter is equivalent to using the output option.

Examples

 > $\mathrm{with}\left(\mathrm{ImageTools}\right):$$\mathrm{img}≔\mathrm{Create}\left(100,200,\left[\left(r,c\right)↦0.25\cdot \left(1+\mathrm{sin}\left(\left(0.005+0.003\cdot c\right)\cdot c\right)\right)\cdot \left(1+\mathrm{sin}\left(0.15\cdot r\right)\right),\left(r,c\right)↦0.5\cdot \left(1+\mathrm{exp}\left(-\frac{r}{50.}\right)\cdot \mathrm{sin}\left(\frac{c}{20.}\right)\right),\left(r,c\right)↦\frac{r}{100.}\right]\right):$
 > $\mathrm{Write}\left("good_img.jpg",\mathrm{img}\right)$
 ${4066}$ (5.1)
 > $\mathrm{img2}≔\mathrm{Read}\left("good_img.jpg"\right)$
 ${{\mathrm{_rtable}}}_{{36893627779577502764}}$ (5.2)
 > $\mathrm{Embed}\left(\mathrm{img2}\right)$

Compatibility

 • The ImageTools[Read] command was updated in Maple 18.