Help for ICTCOMP

PURPOSE:

ICTCOMP simulates Galileo SSI/PWS telemetry data which has been ICT (Integer
Cosine Transform) or losslessly compressed.  The primary purpose of the program
is to provide test data for ICTDECOMP.  ICTDECOMP, in turn, is used to test
ICTD_SLICE (a routine used by the MIPS GLL real-time system to decompress GLL
telemetry data).

EXECUTION:

      ICTCOMP  INP=ipic  OUT=opic  'SSI  user-parameters...
   or ICTCOMP  INP=ipic  OUT=opic  'PWS  user-parameters...

where
 	ipic is an input image in byte format.  The image must be rectangular
             in format.  The number of lines and samples in the image must be
             a multiple of 8.  If the input data is PWS, the sample length must
             be 152 bytes.
        opic is the output compressed image.

The keywords 'SSI and 'PWS specifies whether SSI or PWS telemetry is to be
simulated (default is 'SSI).

RERERENCE:

   Kar-Ming Cheung and Kevin Tong, "Proposed Data Compression Scheme for the
   Galileo S-Band Contingency Mission, Oct 1993, Space and Earth Science Data
   Compression Workshop, Snowbird Utah, April 2, 1993, NASA Conference
   Publication 3191, p. 91- 109.

OPERATION:

ICTCOMP will simulate ICT compressed SSI or PWS data, or losslessly compressed
SSI data, as implemented in the AACS computer on board the Galileo spacecraft.
All three algorithms share the following properties:

  1) The input data is compressed in groups of 8 lines (called a slice).  
  2) Within each slice, the compressor operates on 8x8 sample areas (called
     blocks).

Specific details are covered under the following headings below:

    SIMULATION OF ICT COMPRESSED SSI DATA
    SIMULATION OF LOSSLESSLY COMPRESSED SSI DATA
    SIMULATION OF ICT COMPRESSED PWS DATA

ICT is a "lossy" compression algorithm.  It differs from the standard JPEG
DCT (Discrete Cosine Transform) compression algorithm in that only integer
operations are required.  This feature is crucial in its feasibility for
spacecraft implementation.

Data compression may be applied to a sub-area of an SSI image by specifying
the starting line, starting sample, number of lines, and number of samples of
the region of interest.  E.g. ROI=(1,1,800,800) causes the entire image to be
compressed (the default).  Only the compressed data within the region of
interest is output.

Within the region of interest, a 96x96 pixel area (called a truth window)
may be specified by providing its starting line and starting sample location.
All pixels within the truth window are losslessly compressed.
E.g. TW=(353,353) specifies a truth window in the center of the image (assuming
the input image is 800x800).

ICT compression for a given block consists of the following steps:

    1) An integer cosine transform is applied.
    2) The transform is scaled by dividing each term by the corresponding
       element of a quantizer matrix.
    3) The scaled transform is rearranged in a standard zigzag pattern
       so that the terms are approximately ordered from low to high
       frequency.  Since low-frequency components predominate in flight
       images, this rearrangement usually results in a long string of
       trailing zeroes which compress well.
    4) A Huffman compression is applied.

If a block is part of the truth window, Huffman compression is applied directly
to the raw data.  The Huffman compression applied in this case differs from
Step 4 and is described in SIMULATION OF LOSSLESSLY COMPRESSED SSI DATA below.

For the first block of a slice, the DC term of the transform is encoded
normally.  For each subsequent block, the difference from the previous DC term
is encoded.  If a slice is interrupted by a truth window, the DC term of the
block immediately following the truth window is fully encoded.  (If you didn't
understand this paragraph, don't worry).

A 25-bit sync pattern and 7-bit slice sequence number is placed in front of
each compressed slice.

The quantizer matrix may be chosen from one of the matrices below by
specifying the associated keyword.

         VG0:    8 25 18 25  8 25 18 25
		25 78 56 78 25 78 56 78
		18 56 40 56 18 56 40 56
		25 78 56 78 25 78 56 78
		 8 25 18 25  8 25 18 25
		25 78 56 78 25 78 56 78
		18 56 40 56 18 56 40 56
		25 78 56 78 25 78 56 78

         VG2:    8   25   18   50   24   175   286  1099
                25   78   56  156  100   546   950  3666
                18   56   80  168   89   503   880  3296
                50  156  168  312  175  1092  1787  6786
		24  100   89  175   96   600   984  3722
	       175  546  503 1092  600  3666  6144 19890
	       286  950  880 1787  984  6144 10200 14244
	      1099 3666 3296 6786 3722 19890 14244 19890

          VG3:   8    25    36   125  128  1898  4562  6370
         	25    78   112   468  475  7098 14244 19890
            	36   112   160   559  572  8490 10200 14244
               125   468   559  1794 1898 19890 14244 19890
               128   475   572  1898 2040  6370  4562  6370
              1898  7098  8490 19890 6370 19890 14244 19890
              4562 14244 10200 14244 4562 14244 10200 14244
              6370 19890 14244 19890 6370 19890 14244 19890

Matrix VG0 corresponds to a DCT matrix consisting of unit weights and is the
default.

STEPSIZE is an optional parameter specifying an (integral) quantization
step size (default=8).  Specifying STEPSIZE=8 will multiply all the elements of
the quantizer matrix by 8.  A larger STEPSIZE will result in greater data
compression, with corresponding loss of image resolution.

Prior to Huffman encoding, the frequency terms are recorded in a zig-zag 
pattern so that low frequency terms occur before high-frequency terms. The
keywords 'ZIGZAG and 'ALT may be used to specify the desired pattern.  If
the samples in an 8x8 pixel area are numbered such that the first row contain
samples 0 to 7 (from left to right), the second row samples 8 to 15, etc.,

             0   1   2   3   4   5   6   7
             8   9  10  11  12  13  14  15
            16  17  18  19  20  21  22  23
            24  25  26  27  28  29  30  31
            32  33  34  35  36  37  38  39
            40  41  42  43  44  45  46  47
            48  49  50  51  52  53  54  55
            56  57  58  59  60  61  62  63

then the sample reordering is as follows:

    ZIGZAG:  0   1   5   6  14  15  27  28
             2   4   7  13  16  26  29  42
             3   8  12  17  25  30  41  43
             9  11  18  24  31  40  44  53
            10  19  23  32  39  45  52  54
            20  22  33  38  46  51  55  60
            21  34  37  47  50  56  59  61
            35  36  48  49  57  58  62  63

    ALT      0   1   2   3   4   5   6   7
             8  15  16  20  21  29  30  42
             9  17  19  22  28  31  41  43
            10  18  23  27  32  40  44  53
            11  24  26  33  39  45  52  54
            12  25  34  38  46  51  55  60
            13  35  37  47  50  56  59  61
            14  36  48  49  57  58  62  63

The keywords 'UNIFORM and 'SKEWED may be used to specify the desired Huffman
table.

Each output record will represent the data portion of a compressed SSI
telemetry packet (511 bytes)  The region of interest location and dimensions,
truth window location, quantization matrix, quantization step size, zigzag
table, Huffman table name, and size of the input image (RAWNL and RAWNS) are
stored in the VICAR history label for later use by program ICTDECOMP.

Current values for quantization matrices, zigzag tables, and Huffman tables
are maintained in include file R2LIB:ICTDECOMP.H.

SIMULATION OF LOSSLESSLY COMPRESSED SSI DATA:

Specifying 'LOSSLESS bypasses the ICT compressor and applies the lossless
Huffman compressor to all pixels within the region of interest (see ROI
parameter above).  Specification of ICT parameters TW, STEPSIZE, QM, ZIGZAG,
and HUFTABLE are not applicable in this mode.

For each 8x8 block of a slice, the following operations are performed:

    1) The samples in the block are reordered into a linear array using a
       SNAKESCAN pattern.
    2) Huffman compression is applied.

If the samples in an 8x8 pixel area are numbered such that the first row contain
samples 0 to 7 (from left to right), the second row samples 8 to 15, etc., then
the SNAKESCAN reordering is as follows:

             0   1   2   3   4   5   6   7
            15  14  13  12  11  10   9   8
            16  17  18  19  20  21  22  23
            31  30  29  28  27  26  25  24
            32  33  34  35  36  37  38  39
            47  46  45  44  43  42  41  40
            48  49  50  51  52  53  54  55
            63  62  61  60  59  58  57  56

A 25-bit sync pattern and 7-bit slice sequence number is placed in front of
each compressed slice.

SIMULATION OF COMPRESSED PWS DATA:

ICT compression is applied to all PWS data.  Although the quantization matrix,
zigzag table, and Huffman table may be specified via parameters (see SIMULATION
OF ICT COMPRESSED SSI DATA above), it is anticipated that the standard tables
(default values) will be used during the mission.

The input record length must be 152 bytes.  The input data is processed in
groups of 8 records, representing 8x152 pixel slices.  The slice is divided
into 19 8x8 blocks (8x19=152).  Each of the 19 blocks corresponds to data
samples measured at different (increasing) frequencies.  Instead of using
a single stepsize for the entire slice, PWS will use a 4-element Q factor
vector as follows:

        BLOCK RANGE
           0 to  4              q_factor_vector[0]
           5 to  9              q_factor_vector[1]
          10 to 14              q_factor_vector[2]
          15 to 18              q_factor_vector[3]

PWS is planning to use 7 different sets of quantization factor vectors
as follows:

   SET #     Q-vector
   ----      -----------
    0        33, 42, 53, 66,
    1        20, 27, 36, 44,
    2        10, 15, 18, 22,
    3         6,  8, 11, 13,
    4         3,  5,  8, 10,
    5         2,  2,  4,  5,
    6         1,  1,  3,  3,

Sets 1 - 6 correspond to each of the RTS PWS data rates (5, 10, 15, 20, 30,
and 40 bps).  Set 0 provides a lower overall data rate to be used in the event
that the nominal set designed for 5bps generates too much data.  These
sets correspond to targeted compression ratios of 22:1, 13:1 6.6:1 4.4:1,
3.3:1, 2.2:1 and 1.7:1, or to data rates of 3, 5, 10, 15, 20, 30, and 40 bps.
The above tables may be periodically updated.

Each output record will represent a slice of PWS data (2000 bytes).  The
quantization matrix, quantization step size, zigzag table, Huffman table name,
and size of the input image (RAWNL and RAWNS) are stored in the VICAR history
label for later use by program ICTDECOMP.

EXAMPLES:

  1)  ICTCOMP is used to compress the input SSI image RAW.IMG.  The compressed
      output image is COMP.IMG.  The image is then decompressed using
      ICTDECOMP.  Since no parameters are provided, default values for the
      quantization matrix, stepsize, zigag, and Huffman tables are used.
      The region of interest comprises the entire image and there is no
      truth window.

	ICTCOMP  INP=RAW.IMG  OUT=COMP.IMG
	ICTDECOMP  INP=COMP.IMG  OUT=RECON.IMG

  2) The following example specifies the VG2 quantizer matrix and a stepsize
     of 16:

	ICTCOMP  INP=RAW.IMG  OUT=COMP.IMG  'VG2  STEPSIZE=16
	ICTDECOMP  INP=COMP.IMG  OUT=RECON.IMG

     The parameters need not be specified when running ICTDECOMP since they are
     retrieved automatically from the VICAR label.

  3) The following example compresses PWS data:

	ICTCOMP  INP=RAW.IMG  OUT=COMP.IMG  'PWS  PWLQF=2
	ICTDECOMP  INP=COMP.IMG  OUT=RECON.IMG
        ICTCOMP

PROGRAM HISTORY:

ICTCOMP represents a VICAR conversion of software originally written by
Kar-Ming Cheung and Kevin Tong of the Communications Systems Research Section
of the Jet Propulsion Laboratory.

VICAR conversion: Gary Yagi, June 28 1995
Cognizant programmer: Gary Yagi
Revisions:
  11 Jun 98  RRP  Changed nl to DCTSIZE*roi_yblocks in the print statement
                  to output correct compression ratio.
  02 Jul 98  RRP  Ported to unix. Changed tst pdf to work on vms and unix.
  20 Nov 95  GMY  Fix PWS to reverse order for applying q-vector (FR 87350)
  27 Nov 94  GMY  Fix error in Q-matrix parameter (FR 85636)
   6 Nov 94  GMY  Check TW and ROI for image boundary violations (FR 85813)  
  20 Sep 94  GMY  Add lossless mode for SSI compression
   6 Jul 94  GMY  Add input of PWS Q-factors
  28 Jun 94  GMY  Add truth window, region of interest, and sync codes
             FFM  Add PWS_COMP routine to handle PWS compression 
  14 Jul 93  GMY  Reset SAMP to 0 in WRITECODE.


PARAMETERS:


INP

Input byte image

OUT

Output compressed image.

LOSSLESS

Specifies lossless compression (default is ICT)

ROI

Region of Interest (sl,ss,nl,ns)

TW

Truth Window (sl,ss)

STEPSIZE

Quantization step size.

QM

Quantization matrix

ZIGZAG

Zigzag pattern name

HUFTABLE

Huffman table name

INSTRUMENT

Instrument ('SSI or 'PWS)

PWLQF

PWS quantization factor vector name

See Examples:


Cognizant Programmer: