Description of the .cht format
    [This is a rather inflexible format, that should really be replaced
    with a CGATS style file.]
    
    The .cht format file is
    used to hold the image recognition information that allows the scanin program to align the input image
    with the specified sample boxes.
    
    A raw .cht file can be
    produced by running scanin with the -g option, although this will then need
    cleaning up manually, using a text editor. The cleanup consists of
    deleting any unwanted reference lines from the XLIST and YLISTs,
    adding the the sample box references, and possibly adding the
    expected sample values.
    
    The .cht image recognition
    file is usually set up to recognized a scanned test chart that
    includes the edges of the chart itself, not a cropped version of the chart that excludes the
    edges of the chart itself. This is to allow scanin to be used with scans
    that have just be roughly cropped, without requiring that a scan be
    treated in detail with an application such as Adobe Photoshop.
    
    The keywords and associated data must be used in the following
    order: BOXES, BOX_SHRINK, REF_ROTATION, XLIST,
    YLIST and EXPECTED.
    
    The physical units used for boxes and edge lists are arbitrary units
    (i.e. pixels as generated by scanin -g, but could be mm, inches etc.
    if created  some other way), the only requirement is that the
    sample box definitions need to agree with the X/YLIST definitions.
    Typically if a scanned chart is used to build the reference, the
    units will be pixels of the scanned chart.
    
    The BOXES keyword introduces the list of diagnostic and
    sample boxes. The integer following this keyword must be the total
    number of diagnostic and sample boxes, but not including any fiducual
    marks. The lines following the BOXES keyword must then contain the
    fiducial mark, diagnostic or sample box definitions. Each box
    definition line consists of 11 space separated parameters, and can
    generate a grid of sample or diagnostic boxes:
    
        kl lxs lxe lys lye w h xo yo xi yi
    
    with the following usage:
    
        kl is a key letter.
    
            F is used to define four fiducial marks that may be
    used for manual alignment of an image to the target. The four marks
    are nominally a top left mark, a top right mark, bottom right mark
    and a bottom left mark (ie. clockwise order from top left). The
    parameters are labeled as follows:
     
              F _ _ x0 y0 x1 y1 x2
      y2 x3 y3
      
              Where the first two
    parameters are not used, and a '_' character should be used as a
    place holder, and the follows the X and Y coordinates for the four
    fiducial marks. Typically fiducial marks are
    chosen to be at the corners of the overall bounding box, or at
    corner cross marks on the chart etc. Fiducial marks may be omitted,
    but in this case manual alignment cannot be used.
    
            D is used for a
    diagnostic box which will show up in the diagnostic raster output,
    but is not used as a sample box.  The label information can be
    arbitrary.
        
            X is used for a
    sequence of boxes in which the X label comes first in the
    concatenated sample box label.
            
            Y is used for a
    sequence of boxes in which the Y label comes first in the
    concatenated sample box label.
    
            Boxes are created incrementing
    in the X direction fastest, and the Y direction slowest.
    
        lxs is the X axis starting label. This is
    generally a letter or number, and it will be incremented
    appropriately to reach lxe
    
        lxe is the X axis ending label. When the X
    label reaches this this value (inclusively), the iteration in the X
    direction will reset.
    
        lys is the Y axis starting label. This is
    generally a letter or number, and it will be incremented
    appropriately to reach lye
    
        lye is the Y axis ending label. When the Y
    label reaches this this value (inclusively), the iteration through
    the boxes will end.
    
        The X & Y labels will be concatenated to form
    the sample box label.
    
        A sample label that consists of the character '_'
    is treated as a null label (useful for an array that only iterates
    in one direction).
    
        w, h are the width and height of
    each box in the array.
    
        xo, yo are the origin of the top
    left of the array.
    
        xi, yi are the increments between
    each box in the array.
    
    A blank line should follow the last box definition line.
    
    If leading zero's ('0') are required for a label, they should be
    included in the format. i.e. if you want 1 .. 13 use starting label
    "1" ending label "13".
    If you want 01 .. 13 use starting label "01" ending label "13".
    
    The keyword BOX_SHRINK marks the definition of how much each
    sample box should be shrunk on each edge before sampling the pixel
    values. This allows the sample boxes to be defined at their edges,
    while allowing a safety margin for the pixels actually sampled. The
    units are the same arbitrary units used for the sample box
    definitions.
    
    A blank line should follow this keyword.
    
    The optional REF_ROTATION keyword indicates the rotation in
    radians clockwise of the reference image when the edge lists were
    generated. This amount of rotation is undone to the image before
    applying the sample box location information. The rotation is about
    the origin (the origin is assumed to be upper left corner). If
    omitted, the reference rotation is assumed to be 0.0
    
    A blank line should follow this keyword.
    
    The XLIST is a list of vertical edge reference "ticks",
    along the X axis. Ticks are just edge transitions, typically being
    each edge of the sample boxes, but should include edges of any
    features that have significant width and a length that is at least
    50% of the available space. It is these edge ticks that are used to
    locate the reference cells position within the input raster. The
    integer after the keyword "XLIST" is the number of entries in the
    list. The first number in the column is the offset of the tick from
    the origin, the second number is used to improve the correlation by
    representing the strength of that "tick" relative to the strongest
    tick which will have a value 1.0. Strength is measured by the
    relative length of the edge.
    
    The third number represents the relative number of times this "tick"
    is crossed by lines in the other direction. A line is regarded as
    crossing if part of it is closer to the "tick" line that half the
    distance to the next tick line. The number is normalized so that the
    largest crossing count has a weight of 1.0. This may be set to 1.0
    if it is not known or easily computed.
    
    A blank line should follow the last XLIST edge definition.
    
    The YLIST is same format and details as the XLIST,
    used for horizontal edges.
    
    The EXPECTED keyword introduces an optional list of approximate expected
    sample box color values, allowing better identification of the
    possible rotation of a chart, particularly if it has no asymmetric
    patch shapes or locations in the chart. Following the keyword should
    either be XYZ or LAB, depending on the color space
    used to describe the reference values, then an integer indicating
    the number of entries in the list. NOTE that these are not
    color reference values!
    
    Each following expected color entry consists of four values. The
    first is the sample box label, which should correspond to one of
    those defined by the BOXES entry above. It is an error if no
    corresponding box has been defined. The remaining three values are
    the approximate
    XYZ or L*a*b* color value expected for that sample box. The XYZ
    values are assumed to be scaled to a maximum Y value of 100. An
    expected color value doesn't have to be provided for every defined
    sample box, nor is it expected to be accurate - it just has to
    represent the approximate expected color. (Actual chart reference
    values are provided as a separate CGATS file to scanin).
    
    A blank line should follow the last EXPECTED box value.
    
    
    
    The following is an example .cht file, suitable for a typical Q60
    IT8 scan target.
    
       BOXES 290
          F _ _ _ _ 1 1  615.5 1.5  615 409
          D ALL ALL _ _ 615 409 1 1 0 0
          D MARK MARK _ _ 14 14 1 1 0 0
          Y 1 22 A L 25.625 25.625 26.625 26.625 25.625 25.625
          X GS00 GS23 _ _ 25.625 51.25 0.0 358.75 25.625 0.0
        
        BOX_SHRINK 3.0
        
        REF_ROTATION -0.002006
        
        XLIST 32
          1.799625 1.000000 0.312500
          27.064987 0.874039 0.750000
          52.592403 0.133439 0.687500
          78.196610 0.264191 0.687500
          104.117756 0.165427 0.937500
          129.377994 0.844432 0.937500
          155.144274 0.501218 0.875000
          180.839181 0.491428 0.937500
          206.359758 0.212384 0.937500
          232.038808 0.851851 0.937500
          257.854725 0.162956 0.625000
          283.552463 0.101243 0.812500
          300.534000 0.024750 0.812500
          309.507688 0.093829 1.000000
          334.711314 0.856821 1.000000
          360.428194 0.787677 1.000000
          385.849730 0.748130 0.937500
          386.650071 0.039487 0.687500
          394.630372 0.024725 0.687500
          411.835654 0.802501 0.750000
          414.017731 0.041974 0.937500
          437.133504 0.674062 0.937500
          437.975355 0.103714 1.000000
          462.938460 0.671643 1.000000
          463.880560 0.093836 0.937500
          488.517995 0.679022 1.000000
          514.338544 0.760511 1.000000
          540.037492 0.111108 0.625000
          565.856396 0.133330 0.562500
          591.114717 0.565475 0.562500
          603.447516 0.032097 0.312500
          615.984915 0.829608 0.250000
        
        YLIST 22
          2.477956 0.993407 0.142857
          12.988903 0.016393 0.190476
          14.739109 0.036082 0.190476
          26.746171 0.911487 0.428571
          52.537114 0.303282 0.904762
          78.060317 0.585303 0.857143
          103.498271 0.606862 0.761905
          128.994535 0.567266 0.761905
          154.483041 0.550814 0.714286
          179.935985 0.623055 0.666667
          205.552940 0.350826 0.714286
          212.051372 0.016393 0.714286
          231.153547 0.824618 0.857143
          256.697418 0.744268 0.952381
          282.145841 0.736126 0.904762
          307.899015 0.536075 0.952381
          333.262903 0.903282 0.809524
          340.217754 0.019722 0.190476
          344.988867 0.019671 0.095238
          346.988885 0.018032 0.095238
          358.840278 0.999967 1.000000
          409.201393 1.000000 0.000000
        
        EXPECTED XYZ 264
          A1    3.85 3.22 1.9
          A2    4.89 3.27 1.6
          A3    5.87 3.31 1.33
          A4    6.3 3.38 1.19
          A5    13.01 11.44 7.64
          A6    16.14 11.99 6.81
          A7    19.35 12.41 6.06
          A8    20.41 11.97 5.3
          A9    43.5 42.81 32.65
          A10   45.58 42.37 30.95
          A11   48.99 43.2 29.9
          A12   50.73 44.02 29.96
          A13   74.46 78.76 66.06
          A14   75.66 76.42 64.08
          A15   78.36 81.34 65.41
          A16   70.52 73.3 59.16
          A17   74.98 75.98 60.69
          A18   72.85 77.3 60.25
          A19   73.09 75.52 64.54
          B1    3.47 3.08 1.41
          B2    4.41 3.25 0.9
          B3    5.04 3.23 0.58
          B4    5.19 3.11 0.47
          B5    13.36 11.59 5.56
          B6    15.97 12.03 3.69
          B7    19.2 12.49 2.2
          B8    19.73 11.52 1.17
          B9    42.19 41.84 29.34
          B10   44.83 42.17 25.93
          B11   48.06 42.9 23.01
          B12   49.63 43.08 21.34
          B13   66.21 72.54 64.61
          B14   70.16 67.1 60.33
          B15   75.46 78.69 51.58
          B16   57.47 59.58 47.66
          B17   68.33 66.45 49.05
          B18   63.89 70.29 51.3
          B19   61.12 62.16 59.79
          C1    4.97 4.75 1.98
          C2    5.18 4.65 1.23
          C3    5.51 4.58 0.71
          C4    5.77 4.61 0.67
          C5    24.57 23.44 10.14
          C6    28.1 24.64 5.22
          C7    31.15 25.28 2.2
          C8    30.85 23.68 1.35
          C9    49.16 49.36 32.37
          C10   51.72 50.72 26.53
          C11   55.24 53.14 21.93
          C12   56.87 53.62 18.46
          C13   57.68 65.65 62.7
          C14   63.46 56.66 55.49
          C15   73 76.11 40.78
          C16   44.73 46.38 36.8
          C17   60.64 55.73 38.1
          C18   52.15 60.27 41.5
          C19   48.13 49.18 54.38
          D1    4.19 4.41 1.93
          D2    4.48 4.72 1.24
          D3    4.55 4.78 0.8
          D4    4.32 4.53 0.78
          D5    27.33 28.55 12.95
          D6    28.68 30.04 7.25
          D7    29.51 31.01 3.41
          D8    27.55 28.44 1.83
          D9    56.06 58.19 38.21
          D10   56.03 58.46 30.02
          D11   56.2 59.33 24.44
          D12   56.19 59.41 19.14
          D13   48.21 57.42 59.53
          D14   58.18 49.14 51.36
          D15   70.98 73.73 33.63
          D16   34.31 35.73 28.22
          D17   54.27 47.53 29.58
          D18   41.67 50.64 32.28
          D19   36.95 37.82 48.09
          E1    4.15 4.75 2.03
          E2    4 4.98 1.37
          E3    3.3 4.49 0.86
          E4    3.11 4.3 0.86
          E5    13.11 14.9 7.06
          E6    12.26 15.23 4.18
          E7    11.53 15.57 2.27
          E8    9.69 13.74 1.51
          E9    39.15 42.08 27.33
          E10   37.43 41.51 22.23
          E11   36.99 42.5 18.85
          E12   36.4 42.58 16.27
          E13   39.97 49.81 56.15
          E14   52.08 41.07 46.36
          E15   68.71 70.76 26.45
          E16   25.7 26.97 21.28
          E17   48.53 40.6 22
          E18   31.62 40.82 23.35
          E19   31.19 31.19 43.4
          F1    1.51 1.91 1.06
          F2    1.29 2.04 0.98
          F3    1.16 2.09 0.82
          F4    1.14 2.04 0.8
          F5    6.53 8.25 5.13
          F6    5.61 8.66 4.38
          F7    4.6 8.77 3.7
          F8    3.45 7.63 2.78
          F9    37.8 41.07 30.91
          F10   35.92 40.76 29.03
          F11   35.42 41.99 29.07
          F12   34 41.8 28
          F13   32.13 42.12 51.99
          F14   45.72 33.34 40.77
          F15   66.26 67.29 19.65
          F16   17.02 18.07 14.4
          F17   41.59 32.53 15.16
          F18   26.26 35.26 18.81
          F19   24.3 23.6 37.48
          G1    2.31 3 2.27
          G2    2 3.21 2.58
          G3    1.66 3.21 2.75
          G4    1.58 3.03 2.6
          G5    8.99 11.08 8.79
          G6    7.68 11.3 9.56
          G7    6.52 11.5 10.2
          G8    5.5 10.85 10.55
          G9    38.29 41.75 33.45
          G10   35.83 41.16 34.11
          G11   34.56 41.83 35.63
          G12   33.69 42.14 36.7
          G13   25.95 35.68 48
          G14   40.6 27.62 36.14
          G15   63.72 63.63 14.35
          G16   10.85 11.82 9.58
          G17   37.23 27.64 11.62
          G18   20.28 28.97 14.15
          G19   17.7 16.74 31.7
          H1    2.56 3.04 2.92
          H2    2.34 3.2 4.12
          H3    2.12 3.28 5.43
          H4    2.06 3.18 5.29
          H5    10.07 11.6 11.24
          H6    9.01 11.68 14.81
          H7    8.22 12 19.42
          H8    7.25 11.55 21.45
          H9    39.25 42.31 36.81
          H10   37.58 41.85 40.37
          H11   37.16 43.07 45.79
          H12   36.27 43.78 49.47
          H13   21.47 30.78 44.22
          H14   36.49 23.35 32.38
          H15   61.58 60.55 10.95
          H16   8.21 8.71 6.91
          H17   33.04 23.26 8.38
          H18   16.22 24.35 10.41
          H19   12.86 11.84 26.82
          I1    4.22 4.44 5.28
          I2    4.35 4.48 8.36
          I3    4.4 4.44 11.94
          I4    4.48 4.58 12.17
          I5    15.15 15.78 15.23
          I6    14.56 15.12 19.52
          I7    14.37 14.81 24.48
          I8    14.11 14.76 30.03
          I9    41.03 42.58 36.94
          I10   40.85 42.23 40.73
          I11   40.86 42.33 45.05
          I12   41.31 42.73 47.77
          I13   17.26 25.93 40.23
          I14   32.66 19.63 28.81
          I15   59.37 57.18 7.79
          I16   4.97 5.32 4.32
          I17   28.62 18.88 5.48
          I18   11.58 18.98 7.25
          I19   9.58 8.34 22.87
          I20   0.45 0.4 0.33
          I21   2.28 1.78 0.98
          I22   2.37 1.95 0.85
          J1    2.15 1.9 2.6
          J2    2.57 2 4.72
          J3    2.93 1.95 8.1
          J4    3.15 1.92 10.76
          J5    11.73 11.6 11.81
          J6    12.98 11.93 16.19
          J7    13.91 12.07 20.95
          J8    14.01 11.59 24.35
          J9    40.75 41.22 36.34
          J10   41.26 41.07 39.74
          J11   42.63 41.68 44.51
          J12   44.02 41.78 49.25
          J13   13.82 21.69 35.98
          J14   28.87 16.33 25.08
          J15   56.04 52.29 4.97
          J16   2.46 2.63 2.29
          J17   24.04 14.75 3.15
          J18   8.12 14.49 4.55
          J19   5.98 4.79 17.76
          J20   8.26 5.37 1.04
          J21   11.52 7.81 1.62
          J22   14.67 10.72 2.6
          K1    5.63 4.7 4.86
          K2    6.74 4.58 7.23
          K3    8.04 4.48 9.73
          K4    9.39 4.76 11.79
          K5    16.66 15.39 14.44
          K6    18.72 15.18 18.23
          K7    21.56 15.5 22.97
          K8    23 15.02 25.37
          K9    42.5 42.02 36.05
          K10   44.55 41.63 39.71
          K11   47.19 41.96 44.03
          K12   49.9 43.14 47.21
          K13   10.61 17.44 31.24
          K14   24.84 13.19 21
          K15   53.12 48.05 3.19
          K16   1.05 1.14 1.13
          K17   19.93 11.34 1.67
          K18   5.3 10.47 2.73
          K19   3.95 2.76 13.94
          K20   30.61 26.43 11.04
          K21   34.91 29.6 11.78
          K22   38.95 34.57 18.4
          L1    3.88 3.12 2.32
          L2    4.93 3.2 2.69
          L3    5.75 3.14 3.02
          L4    7.31 3.79 3.4
          L5    13.29 11.54 9.39
          L6    16.22 11.73 10.32
          L7    19.95 12.08 12.06
          L8    20.79 11.31 12.01
          L9    43.22 42.09 33.78
          L10   45.52 41.88 34.65
          L11   49.04 42.87 35.98
          L12   51.03 43.83 37.78
          L13   7.45 12.77 25.59
          L14   21.26 10.76 17.73
          L15   49.45 43.12 2.14
          L16   0.47 0.49 0.5
          L17   16.04 8.49 0.78
          L18   2.91 6.5 1.39
          L19   2.5 1.45 10.28
          L20   38.7 33.98 20.86
          L21   39.36 35.23 21.23
          L22   41.36 38.77 23.51
          GS0    79.47 82.51 69.04
          GS1    72.62 74.94 59.17
          GS2    63.15 65.11 51.57
          GS3    54.72 56.51 45.03
          GS4    48.1 49.81 39.24
          GS5    42.22 43.64 34.45
          GS6    37.33 38.7 30.5
          GS7    32.38 33.61 26.11
          GS8    27.56 28.7 22.11
          GS9    22.5 23.4 17.99
          GS10   18.77 19.55 14.83
          GS11   15.48 16.08 12.04
          GS12   12.69 13.29 9.98
          GS13   10.35 10.81 7.97
          GS14   8.39 8.77 6.37
          GS15   6.45 6.79 4.97
          GS16   4.95 5.18 3.7
          GS17   3.58 3.82 2.76
          GS18   2.76 2.89 2.06
          GS19   1.97 2.08 1.45
          GS20   1.22 1.31 0.98
          GS21   1 1.05 0.74
          GS22   0.87 0.89 0.65
          GS23   0.34 0.32 0.32