The View_m Script
by Zachary X. Reiter and Clifford A. Reiter
October 2002

The image3 addon contains the script, view_m.ijs, which defines functions that may be used to display images and data. Images may be given as a file name or as one of the standard data forms for images as noted below. Data is assumed to be matrix whose values are to be visualized via coloring.

The Main Functions

The syntax of the main functions are as follows.

The Data Forms for Images are:

  1. h by w by 3 array of integers (range 0-255): this is the main data form
  2. h by w by 3 array of bytes (characters): compact data form
  3. h by w by 1 array of integers (range 0-255) or bytes: Grayscale image
  4. (p;B) where p is an integer palette of RGB values (0-255) and B is an h by w array of indices into the palette.
The left argument (adverb) of write_image may be data in any of those forms. The grayscale format is primarily intended for access to Jpeg grayscale images. Paletted images are promoted to 24 bit images before being saved except for *.bmp and *.png files which are saved as 8-bit images.

Palettes

Three standard palettes are defined by the script.

Several Examples

Some examples appear at the end of the view_m.ijs script itself illustrate usage. Some of those are repeated here:
view_image addon_path,'atkiln.jpg'   NB. load a medium size image
view_image 500#,:3#"0 i.256          NB. grayscale as integers
view_image a.{~500#,:3#"0 i.256      NB. grayscale as raw
view_image P256;500#,:i.256          NB. Hues

view_data (+./ . * |:) #:i.2^8       NB. Sierpinski triangle
view_data (+./ . *. |:) 3 3 3 3 3#:i.3^5  NB. Sierpinski carpet
sin3data=:|.(+&(1&o.) + 1&o.@(+&.*:))"0/~ 14*(i:%]) 200
view_data sin3data                   NB. linear scale; b/w peak/valley
P256 view_data sin3data              NB. linear scale
view_data 256 cile sin3data          NB. optimal contrast; b/w peak/valley
P256 view_data 256 cile sin3data     NB. optimal contrast
view_data 1+254 cile sin3data        NB. use 254 hues to show data with 
                                     NB. optimal contrast; black/white 
                                     NB. reserved for later use.

Link to:
Image3 Main Help