next up previous contents
Next: Fourier commands Up: Image processing Previous: Histograms

Conversions between images and data frames

  

f2i Convert a data frame into a grayscale image
-d <frame> input frame name.
-iout <image> output image name.
[ -verbose ] give extra information during conversion
i2f Convert a grayscale 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 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.

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.

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.

# Load an image 
NDA> loadimg gray.gif
# Convert the image to frame named "imgframe"
NDA> i2f -i gray -dout imgframe
# Save the frame to disk
NDA> save imgframe
# At this point operations could be performed to "imgframe"
...
# At the end convert the data frame back to an image
NDA> f2i -d imgframe -iout newgray


next up previous contents
Next: Fourier commands Up: Image processing Previous: Histograms

Anssi Lensu
Wed Oct 6 12:57:48 EET DST 1999