lvgamut

Input

     image          pointer to xvimage structure to be processed
     ncolors        number of colors allowed in the output image
     bits           number of bits of  precision  for  the  color
                    prequantization
     fraction       allocation ratio of color split methods.  0.0
                    is population, 1.0 is subspace 2-norm.

Output

     image          holds the result of the operation.  The  out-
                    put  data  type is the same as the input data

Type

     Return Value:  1 on success, 0 on failure.

Modifications

     Jeremy Worley Fri Aug  2 11:18:33 CDT 1991
                                             Cast  operations  in
                                             an  abs to signed to
                                             prevent  core  dumps
                                             due to a weakness in
                                             code  generated   by
                                             Cray's scc compiler.
     Scott Wilson, Sat Aug 24 1991           Added     diagnostic
                                             message    for   the
                                             number   of   colors
                                             found in the image.

Description

     _l_v_g_a_m_u_t takes a 3 band multi-spectral image, where each band
     would  normally  represent  one  component  of  a 24-bit RGB
     image, and generates a pseudo color image with  a  specified
     number  of  colors  that can be displayed using editimage or
     putimage.  The object is to make the displayable image  look
     like  the  true  24-bit  RGB image even though the number of
University of New MexicoLast change: 08/24/91                     1
lvgamut(3)             C LIBRARY FUNCTIONS             lvgamut(3)
     colors is greatly restricted.
     The color compression is performed by isolating clusters  of
     "neighboring"  colors in a three dimensional histogram, with
     each axis being one of the color components.   The  clusters
     are  obtained  using  a modified version of Heckberts median
     cut.  The true colors are then matched to the closest  clus-
     ter,  and  the  input RGB triplet is then re-mapped to an n-
     color pseudo color image.
     To keep the histogram from becoming exceedingly  large  (max
     of  around  2^24  bytes), one may need to  quantize the grey
     levels of the input bands to less than 8 bits.  6  bits  (64
     levels)  gives results that are reasonable in a short amount
     of time. The number of bits that  are  kept  is  called  the
     color  precision,  which can be specified at execution time.
     The general tradeoff is  that smaller  precision  is  faster
     and  takes  less memory, but it looks worse too. High preci-
     sion takes longer and great gobs of memory, but looks  good,
     provided that a reasonable number (say 128) colors is speci-
     fied.  The execution time is very  dependent  on  the  image
     statistics.  In  general, a small number of colors is faster
     than a large number of colors.  In either case, if the image
     has  good spatial color coherence, execution time is greatly
     reduced.
     The allocation fraction (-r) controls  how  large  areas  of
     nearly the same color are handled. An allocation fraction of
     0.0 will cause the large areas to be  broken  into  as  many
     colors  as  possible  with the largest areas of a particular
     color range being broken first. An  allocation  fraction  of
     1.0  will  attempt  to  preserve  the _d_e_t_a_i_l in the image be
     preserving the color range of all parts of the image at  the
     expense  of  smooth coloring of the larger areas. An alloca-
     tion fraction of around 0.2 to 0.5 gives very  good  results
     on most images.
     As a special note, be sure that the input image  has  a  map
     that has one-to-one correspondence to the pixel values (i.e.
     the pixel value is the grey level). If this is not the case,
     use vmapdata(1) to convert to a linear map.
     Note that image is used for both the input xvimage structure
     and the resulting output xvimage structure.  This is done to
     save space, but you must be careful not to overwrite  impor-
     tant data.
     If the input image contains less than the number  of  colors
     requested then the output image will contain only the number
     of colors present in the input image. A diagnostic  messsage
     will  printed  to STDERR when this occurs, provided that the
     KHOROS_VERBOSE environment variable is set.
University of New MexicoLast change: 08/24/91                     2
lvgamut(3)             C LIBRARY FUNCTIONS             lvgamut(3)
     No dithering is done by lvgamut. Dithering  in  color  space
     can  often  cause  the  image  to look very noisy due to the
     color sensitivity of the eye. The result images from lvgamut
     may  display  some banding effects, but these are often more
     tolerable visually than the noise that would result  from  a
     color dithering process.
     If the KHOROS_VERBOSE environment variable is  set  then  an
     additional diagnostic message, the number of colors actually
     found in the image, will be printed. The color count is sub-
     ject to the color precision specified by the -p option.

See also

     vgamut(1), intro(3), vipl(3),  verror(3),  vutils(3)  lvmap-
     data(1)
RESTRICTIONS
     _v_g_a_m_u_t works only on BYTE imagesk with three bands of data.

Author

     Scott Wilson
COPYRIGHT
     Copyright  1991,  University  of  New  Mexico.   All  rights
     reserved.
University of New MexicoLast change: 08/24/91                     3