next up previous contents
Next: Converting graphs into pixel Up: Image conversions and cropping Previous: Image conversions and cropping

Conversions between images and data frames

  

f2i Convert a data frame into an image
-d <frame> input frame name.
-iout <image> output image name.
[ -verbose ] output extra info during conversion
[ -bgimg <bgimage> ] background image
[ -bgcol <gray | r g b> ] background gray level or rgb color
[ -xsize <x> ] horizontal dimension for output image
[ -ysize <y> ] vertical dimension for output image
i2f Convert an image into a data frame
-i <image> input image name
-dout <frame> output frame name
[ -gray ] convert color image to grayscale
[ -rgb ] convert grayscale image to indexed

Command f2i converts a frame into an image. The frame must contain three fields. The first field is used for the x coordinate, second for the y coordinate and third for the grayscale level of the pixels. If there exists five fields then the last three fields are used as RGB values for the image and a palette is created before converting the frame into an image. The option -verbose provides the user extra information while converting the frame into an indexed image. If there are less pixels in the input data frame than in the output image, other pixels are specified by background image and background color. Size of output image is based on background image and given pixels if size is not specified explicitly using -xsize and -ysize.

Command i2f converts an image into a data frame. If the input image is grayscale then the output frame contains three fields x, y and img, where fields x and y are the corresponding coordinates of pixel img. The field img contains grayscale level of pixel. When using option -rgb the frame contains fields x, y, red, green, blue, which contain the RGB values of the pixel. If the input image is indexed, the output frame contains five fields x, y, red, green, blue, unless option -gray is used, in which case the image is converted into a grayscale image before making the conversion to a frame.

Example: This simple example reads a grayscale image gray.gif into namespace and then converts it into a data frame and back again into an image.

NDA> loadimg gray.gif
NDA> i2f -i gray -dout imgframe
# Save the frame to disk
NDA> save imgframe
...
# After some operations convert the result back to an image
NDA> f2i -d newimgfrm -iout newgray


next up previous contents
Next: Converting graphs into pixel Up: Image conversions and cropping Previous: Image conversions and cropping

Anssi Lensu
Thu May 17 15:00:44 EET DST 2001