CRIMP
Artifact [940ff290f1]
Not logged in

Artifact 940ff290f1a232ce1c61d6cf442ab195ea982fec:


# -*- tcl -*-
# -------------------------------------------------------------------------

source [file join \
            [file dirname [file join [pwd] [info script]]] \
            testutilities.tcl]

testsNeedTcl     8.5
testsNeedTcltest 2

support { useLocalFile synth.tcl }
support { useC [mainPath _test/lib]/crimp_core* crimp::core no }
testing { useC [mainPath _test/lib]/crimp*      crimp       no }

# TODO: test monotonicity of various functions ((de)gamma, sqrt, log)
# TODO: want visualization of the results for better verification => 256x256 b/w image.

# -------------------------------------------------------------------------
## Supporting commands, mapping tables and images.
##
## Note: Mapping tables are lists of 256 integers in the range [0-255]
##       which map pixel values (0-255, used to index the list) to these
##       integers. In this way they describe a function [0-255] --> [0..255].
##
##       Mapping images are mapping tables converted to 256x1 grey8 images.
# -------------------------------------------------------------------------

test crimp-table-1.0 {image tables, wrong\#args, not enough} -body {
    crimp table
} -returnCodes error -result {wrong # args: should be "crimp table subcommand ?argument ...?"}

test crimp-table-1.1 {image tables, invalid method} -body {
    crimp table BOGUS
} -returnCodes error -result {unknown or ambiguous subcommand "BOGUS": must be compose, degamma, eval, fgauss, gamma, gauss, identity, invers, linear, log, quantize, solarize, sqrt, stretch, or threshold}

# -------------------------------------------------------------------------

test crimp-table-2.0 {image tables, eval, wrong\#args, not enough} -body {
    crimp table eval
} -returnCodes error -result {wrong # args: should be "crimp table eval subcommand ?argument ...?"}

test crimp-table-2.1 {image tables, eval, invalid method} -body {
    crimp table eval BOGUS
} -returnCodes error -result {unknown or ambiguous subcommand "BOGUS": must be clamp, or wrap}

# -------------------------------------------------------------------------

test crimp-table-3.0 {image tables, eval wrap, wrong\#args, not enough} -body {
    crimp table eval wrap
} -returnCodes error -result {wrong # args: should be "crimp table eval wrap cmdprefix"}

test crimp-table-3.1 {image tables, eval wrap, wrong\#args, too many} -body {
    crimp table eval wrap CMD bogus
} -returnCodes error -result {wrong # args: should be "crimp table eval wrap cmdprefix"}

test crimp-table-3.2 {image tables, eval wrap} -body {
    list [crimp table eval wrap {apply {{x} {
        global in out

        set z [expr {10*($x - 10)}]

        lappend in $x
        lappend out $z
        return $z
    }}}] $in $out
    # compare table-4.2
} -cleanup {
    unset in out
} -result [list \
               [list  155 165 175 185 195 205 215 225 235 245  0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250   5  15  25  35  45  55  65  75  85  95 105 115 125 135 145 155 165 175 185 195 205 215 225 235 245 255  10  20  30  40  50  60  70  80  90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250  5   15  25  35  45  55  65  75  85  95 105 115 125 135 145 155 165 175 185 195 205 215 225 235 245 255 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 5 15 25 35 45 55 65 75 85 95 105 115 125 135 145 155 165 175 185 195 205 215 225 235 245 255 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 5 15 25 35 45 55 65 75 85 95 105 115 125 135 145 155 165 175 185 195 205 215 225 235 245 255 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 5 15 25 35 45 55 65 75 85 95 105 115 125 135 145 155] \
               [list    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  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255] \
               [list -100 -90 -80 -70 -60 -50 -40 -30 -20 -10  0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490 500 510 520 530 540 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690 700 710 720 730 740 750 760 770 780 790 800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990 1000 1010 1020 1030 1040 1050 1060 1070 1080 1090 1100 1110 1120 1130 1140 1150 1160 1170 1180 1190 1200 1210 1220 1230 1240 1250 1260 1270 1280 1290 1300 1310 1320 1330 1340 1350 1360 1370 1380 1390 1400 1410 1420 1430 1440 1450 1460 1470 1480 1490 1500 1510 1520 1530 1540 1550 1560 1570 1580 1590 1600 1610 1620 1630 1640 1650 1660 1670 1680 1690 1700 1710 1720 1730 1740 1750 1760 1770 1780 1790 1800 1810 1820 1830 1840 1850 1860 1870 1880 1890 1900 1910 1920 1930 1940 1950 1960 1970 1980 1990 2000 2010 2020 2030 2040 2050 2060 2070 2080 2090 2100 2110 2120 2130 2140 2150 2160 2170 2180 2190 2200 2210 2220 2230 2240 2250 2260 2270 2280 2290 2300 2310 2320 2330 2340 2350 2360 2370 2380 2390 2400 2410 2420 2430 2440 2450]]

# -------------------------------------------------------------------------

test crimp-table-4.0 {image tables, eval clamp, wrong\#args, not enough} -body {
    crimp table eval clamp
} -returnCodes error -result {wrong # args: should be "crimp table eval clamp cmdprefix"}

test crimp-table-4.1 {image tables, eval clamp, wrong\#args, too many} -body {
    crimp table eval clamp CMD bogus
} -returnCodes error -result {wrong # args: should be "crimp table eval clamp cmdprefix"}

test crimp-table-4.2 {image tables, eval clamp} -body {
    list [crimp table eval clamp {apply {{x} {
        global in out

        set z [expr {10*($x - 10)}]

        lappend in $x
        lappend out $z
        return $z
    }}}] $in $out
    # compare table-3.2
} -cleanup {
    unset in out
} -result [list \
               [list    0   0   0   0   0   0   0   0   0   0  0   10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250   255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255  255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255] \
               [list    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  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109  110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255] \
               [list -100 -90 -80 -70 -60 -50 -40 -30 -20 -10  0   10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250   260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490 500 510 520 530 540 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690 700 710 720 730 740 750 760 770 780 790 800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990 1000 1010 1020 1030 1040 1050 1060 1070 1080 1090 1100 1110 1120 1130 1140 1150 1160 1170 1180 1190 1200 1210 1220 1230 1240 1250 1260 1270 1280 1290 1300 1310 1320 1330 1340 1350 1360 1370 1380 1390 1400 1410 1420 1430 1440 1450 1460 1470 1480 1490 1500 1510 1520 1530 1540 1550 1560 1570 1580 1590 1600 1610 1620 1630 1640 1650 1660 1670 1680 1690 1700 1710 1720 1730 1740 1750 1760 1770 1780 1790 1800 1810 1820 1830 1840 1850 1860 1870 1880 1890 1900 1910 1920 1930 1940 1950 1960 1970 1980 1990 2000 2010 2020 2030 2040 2050 2060 2070 2080 2090 2100 2110 2120 2130 2140 2150 2160 2170 2180 2190 2200 2210 2220 2230 2240 2250 2260 2270 2280 2290 2300 2310 2320 2330 2340 2350 2360 2370 2380 2390 2400 2410 2420 2430 2440 2450]]

# -------------------------------------------------------------------------

test crimp-table-5.0 {image tables, compose, wrong\#args, not enough} -body {
    crimp table compose
} -returnCodes error -result {wrong # args: should be "crimp table compose f g"}

test crimp-table-5.1 {image tables, compose, wrong\#args, not enough} -body {
    crimp table compose F
} -returnCodes error -result {wrong # args: should be "crimp table compose f g"}

test crimp-table-5.2 {image tables, compose, wrong\#args, too many} -body {
    crimp table compose F G bogus
} -returnCodes error -result {wrong # args: should be "crimp table compose f g"}

test crimp-table-5.3 {image tables, compose} -body {
    crimp table compose \
        [crimp table identity] \
        [crimp table invers]
} -result [lreverse [iota 256]] ; # identity after inverse = inverse

test crimp-table-5.3 {image tables, compose} -body {
    crimp table compose \
        [crimp table invers] \
        [crimp table invers]
} -result [iota 256] ; # double inverse = identity

# -------------------------------------------------------------------------

test crimp-table-6.0 {image tables, identity, wrong\#args, too many} -body {
    crimp table identity BOGUS
} -returnCodes error -result {wrong # args: should be "crimp table identity"}

test crimp-table-6.1 {image tables, identity} -body {
    crimp table identity
} -result [iota 256]

# -------------------------------------------------------------------------

test crimp-table-7.0 {image tables, invers, wrong\#args, too many} -body {
    crimp table invers BOGUS
} -returnCodes error -result {wrong # args: should be "crimp table invers"}

test crimp-table-7.1 {image tables, invers} -body {
    crimp table invers
} -result [lreverse [iota 256]]

# -------------------------------------------------------------------------

test crimp-table-8.0 {image tables, solarize, wrong\#args, not enough} -body {
    crimp table solarize
} -returnCodes error -result {wrong # args: should be "crimp table solarize n"}

test crimp-table-8.1 {image tables, solarize, wrong\#args, too many} -body {
    crimp table solarize N bogus
} -returnCodes error -result {wrong # args: should be "crimp table solarize n"}

test crimp-table-8.2 {image tables, solarize} -body {
    crimp table solarize 0
} -result [lreverse [iota 256]]

test crimp-table-8.3 {image tables, solarize} -body {
    crimp table solarize 1
} -result [concat 0 [lreverse [iota 255]]]

test crimp-table-8.4 {image tables, solarize} -body {
    crimp table solarize -1
} -result [lreverse [iota 256]]

test crimp-table-8.5 {image tables, solarize} -body {
    crimp table solarize 128
} -result [concat [iota 128] [lreverse [iota 128]]]

test crimp-table-8.6 {image tables, solarize} -body {
    crimp table solarize 255
} -result [concat [iota 255] 0]

test crimp-table-8.7 {image tables, solarize} -body {
    crimp table solarize 256
} -result [iota 256]

test crimp-table-8.8 {image tables, solarize} -body {
    crimp table solarize 254
} -result [concat [iota 254] {1 0}]

# -------------------------------------------------------------------------

test crimp-table-9.0 {image tables, gamma, wrong\#args, not enough} -body {
    crimp table gamma
} -returnCodes error -result {wrong # args: should be "crimp table gamma y"}

test crimp-table-9.1 {image tables, gamma, wrong\#args, too many} -body {
    crimp table gamma Y bogus
} -returnCodes error -result {wrong # args: should be "crimp table gamma y"}

test crimp-table-9.2 {image tables, gamma} -body {
    crimp table gamma 0
    # all white
} -result [lrepeat 256 255]

test crimp-table-9.3 {image tables, gamma} -body {
    crimp table gamma 0.1
    # near all white
} -result {0 147 157 164 168 172 175 178 180 183 184 186 188 189 191 192 193 195 196 197 198 199 200 200 201 202 203 204 204 205 206 207 207 208 208 209 210 210 211 211 212 212 213 213 214 214 215 215 216 216 217 217 218 218 218 219 219 220 220 220 221 221 221 222 222 222 223 223 223 224 224 224 225 225 225 226 226 226 227 227 227 227 228 228 228 228 229 229 229 230 230 230 230 231 231 231 231 232 232 232 232 232 233 233 233 233 234 234 234 234 234 235 235 235 235 235 236 236 236 236 236 237 237 237 237 237 238 238 238 238 238 239 239 239 239 239 239 240 240 240 240 240 240 241 241 241 241 241 241 242 242 242 242 242 242 243 243 243 243 243 243 244 244 244 244 244 244 244 245 245 245 245 245 245 245 246 246 246 246 246 246 246 247 247 247 247 247 247 247 247 248 248 248 248 248 248 248 249 249 249 249 249 249 249 249 249 250 250 250 250 250 250 250 250 251 251 251 251 251 251 251 251 251 252 252 252 252 252 252 252 252 252 253 253 253 253 253 253 253 253 253 254 254 254 254 254 254 254 254 254 254 255 255 255 255 255}

test crimp-table-9.4 {image tables, gamma} -body {
    crimp table gamma 0.5
    # true gamma in between.
} -result {0 16 23 28 32 36 39 42 45 48 50 53 55 58 60 62 64 66 68 70 71 73 75 77 78 80 81 83 84 86 87 89 90 92 93 94 96 97 98 100 101 102 103 105 106 107 108 109 111 112 113 114 115 116 117 118 119 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 135 136 137 138 139 140 141 142 143 144 145 145 146 147 148 149 150 151 151 152 153 154 155 156 156 157 158 159 160 160 161 162 163 164 164 165 166 167 167 168 169 170 170 171 172 173 173 174 175 176 176 177 178 179 179 180 181 181 182 183 183 184 185 186 186 187 188 188 189 190 190 191 192 192 193 194 194 195 196 196 197 198 198 199 199 200 201 201 202 203 203 204 204 205 206 206 207 208 208 209 209 210 211 211 212 212 213 214 214 215 215 216 217 217 218 218 219 220 220 221 221 222 222 223 224 224 225 225 226 226 227 228 228 229 229 230 230 231 231 232 233 233 234 234 235 235 236 236 237 237 238 238 239 240 240 241 241 242 242 243 243 244 244 245 245 246 246 247 247 248 248 249 249 250 250 251 251 252 252 253 253 254 254 255}

test crimp-table-9.5 {image tables, gamma} -body {
    crimp table gamma 1
    # identity, linear ramp
} -result [iota 256]

# TODO: gamma, out of range [0...1]

# -------------------------------------------------------------------------

test crimp-table-10.0 {image tables, degamma, wrong\#args, too many} -body {
    crimp table degamma
} -returnCodes error -result {wrong # args: should be "crimp table degamma y"}

test crimp-table-10.1 {image tables, degamma, wrong\#args, too many} -body {
    crimp table degamma Y bogus
} -returnCodes error -result {wrong # args: should be "crimp table degamma y"}

test crimp-table-10.2 {image tables, degamma} -body {
    crimp table degamma 0
    # all black
} -result N/A -constraints OutOfDomain/DivByZero

test crimp-table-10.3 {image tables, degamma} -body {
    crimp table degamma 0.1
    # near all black
} -result {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 5 5 5 6 6 6 7 7 7 8 8 9 9 10 10 11 11 12 13 13 14 15 16 17 17 18 19 20 21 22 24 25 26 27 29 30 32 33 35 37 38 40 42 44 46 48 51 53 56 58 61 64 67 70 73 76 80 83 87 91 95 99 103 108 113 118 123 128 133 139 145 151 157 164 171 178 185 193 201 209 218 227 236 245 255}

test crimp-table-10.4 {image tables, degamma} -body {
    crimp table degamma 0.5
    # true gamma in between.
} -result {0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9 10 10 11 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 23 23 24 24 25 26 26 27 28 28 29 30 30 31 32 32 33 34 35 35 36 37 38 38 39 40 41 42 42 43 44 45 46 47 47 48 49 50 51 52 53 54 55 56 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 73 74 75 76 77 78 79 80 81 82 84 85 86 87 88 89 91 92 93 94 95 97 98 99 100 102 103 104 105 107 108 109 111 112 113 115 116 117 119 120 121 123 124 126 127 128 130 131 133 134 136 137 139 140 142 143 145 146 148 149 151 152 154 155 157 158 160 162 163 165 166 168 170 171 173 175 176 178 180 181 183 185 186 188 190 192 193 195 197 199 200 202 204 206 207 209 211 213 215 217 218 220 222 224 226 228 230 232 233 235 237 239 241 243 245 247 249 251 253 255}

test crimp-table-10.5 {image tables, degamma} -body {
    crimp table degamma 1
    # identity, linear ramp
} -result [iota 256]

# TODO: degamma, out of range (0...1]
# TODO: gamma/degamma composition - should be identity, or near to it.
# if not exact (fp cal inside) maybe compute difference/distance and accept under some limit.

# -------------------------------------------------------------------------

test crimp-table-11.0 {image tables, sqrt, wrong\#args, too many} -body {
    crimp table sqrt MAX bogus
} -returnCodes error -result {wrong # args: should be "crimp table sqrt ?max?"}

test crimp-table-11.1 {image tables, sqrt} -body {
    crimp table sqrt 0
} -returnCodes error -result {domain error: argument not in valid range}
# TODO: sqrt, 0 out of range, better message

test crimp-table-11.2 {image tables, sqrt} -body {
    crimp table sqrt 1
    # near all white
} -result [concat 0 [lrepeat 255 255]]

test crimp-table-11.3 {image tables, sqrt} -body {
    crimp table sqrt 128
} -result {0 23 32 39 45 50 55 60 64 68 71 75 78 81 84 87 90 93 96 98 101 103 106 108 110 113 115 117 119 121 123 125 128 129 131 133 135 137 139 141 143 144 146 148 150 151 153 155 156 158 159 161 163 164 166 167 169 170 172 173 175 176 177 179 180 182 183 184 186 187 189 190 191 193 194 195 196 198 199 200 202 203 204 205 207 208 209 210 211 213 214 215 216 217 219 220 221 222 223 224 225 227 228 229 230 231 232 233 234 235 236 237 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255}

test crimp-table-11.4 {image tables, sqrt} -body {
    crimp table sqrt 254
} -result {0 16 23 28 32 36 39 42 45 48 51 53 55 58 60 62 64 66 68 70 72 73 75 77 78 80 82 83 85 86 88 89 91 92 93 95 96 97 99 100 101 102 104 105 106 107 109 110 111 112 113 114 115 116 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 139 140 141 142 143 144 145 146 147 148 148 149 150 151 152 153 153 154 155 156 157 158 158 159 160 161 162 162 163 164 165 166 166 167 168 169 169 170 171 172 172 173 174 175 175 176 177 177 178 179 180 180 181 182 182 183 184 185 185 186 187 187 188 189 189 190 191 191 192 193 193 194 195 195 196 197 197 198 199 199 200 200 201 202 202 203 204 204 205 206 206 207 207 208 209 209 210 210 211 212 212 213 213 214 215 215 216 216 217 218 218 219 219 220 221 221 222 222 223 223 224 225 225 226 226 227 227 228 229 229 230 230 231 231 232 232 233 234 234 235 235 236 236 237 237 238 238 239 239 240 241 241 242 242 243 243 244 244 245 245 246 246 247 247 248 248 249 249 250 250 251 251 252 252 253 253 254 254 255 255}

test crimp-table-11.5 {image tables, sqrt} -body {
    crimp table sqrt 255
} -result {0 16 23 28 32 36 39 42 45 48 50 53 55 58 60 62 64 66 68 70 71 73 75 77 78 80 81 83 84 86 87 89 90 92 93 94 96 97 98 100 101 102 103 105 106 107 108 109 111 112 113 114 115 116 117 118 119 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 135 136 137 138 139 140 141 142 143 144 145 145 146 147 148 149 150 151 151 152 153 154 155 156 156 157 158 159 160 160 161 162 163 164 164 165 166 167 167 168 169 170 170 171 172 173 173 174 175 176 176 177 178 179 179 180 181 181 182 183 183 184 185 186 186 187 188 188 189 190 190 191 192 192 193 194 194 195 196 196 197 198 198 199 199 200 201 201 202 203 203 204 204 205 206 206 207 208 208 209 209 210 211 211 212 212 213 214 214 215 215 216 217 217 218 218 219 220 220 221 221 222 222 223 224 224 225 225 226 226 227 228 228 229 229 230 230 231 231 232 233 233 234 234 235 235 236 236 237 237 238 238 239 240 240 241 241 242 242 243 243 244 244 245 245 246 246 247 247 248 248 249 249 250 250 251 251 252 252 253 253 254 254 255}

test crimp-table-11.6 {image tables, sqrt} -body {
    crimp table sqrt 256
} -result {0 16 23 28 32 36 39 42 45 48 50 53 55 57 60 62 64 66 68 69 71 73 75 76 78 80 81 83 84 86 87 89 90 92 93 94 96 97 98 100 101 102 103 105 106 107 108 109 110 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 128 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 143 144 145 146 147 148 149 150 150 151 152 153 154 155 155 156 157 158 159 159 160 161 162 163 163 164 165 166 166 167 168 169 169 170 171 172 172 173 174 175 175 176 177 177 178 179 180 180 181 182 182 183 184 184 185 186 187 187 188 189 189 190 191 191 192 193 193 194 195 195 196 196 197 198 198 199 200 200 201 202 202 203 203 204 205 205 206 207 207 208 208 209 210 210 211 211 212 213 213 214 214 215 216 216 217 217 218 219 219 220 220 221 221 222 223 223 224 224 225 225 226 227 227 228 228 229 229 230 230 231 232 232 233 233 234 234 235 235 236 236 237 237 238 239 239 240 240 241 241 242 242 243 243 244 244 245 245 246 246 247 247 248 248 249 249 250 250 251 251 252 252 253 254 254 255}

test crimp-table-11.6 {image tables, sqrt} -body {
    crimp table sqrt
} -result {0 16 23 28 32 36 39 42 45 48 50 53 55 58 60 62 64 66 68 70 71 73 75 77 78 80 81 83 84 86 87 89 90 92 93 94 96 97 98 100 101 102 103 105 106 107 108 109 111 112 113 114 115 116 117 118 119 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 135 136 137 138 139 140 141 142 143 144 145 145 146 147 148 149 150 151 151 152 153 154 155 156 156 157 158 159 160 160 161 162 163 164 164 165 166 167 167 168 169 170 170 171 172 173 173 174 175 176 176 177 178 179 179 180 181 181 182 183 183 184 185 186 186 187 188 188 189 190 190 191 192 192 193 194 194 195 196 196 197 198 198 199 199 200 201 201 202 203 203 204 204 205 206 206 207 208 208 209 209 210 211 211 212 212 213 214 214 215 215 216 217 217 218 218 219 220 220 221 221 222 222 223 224 224 225 225 226 226 227 228 228 229 229 230 230 231 231 232 233 233 234 234 235 235 236 236 237 237 238 238 239 240 240 241 241 242 242 243 243 244 244 245 245 246 246 247 247 248 248 249 249 250 250 251 251 252 252 253 253 254 254 255}

# -------------------------------------------------------------------------

test crimp-table-12.0 {image tables, log, wrong\#args, too many} -body {
    crimp table log MAX bogus
} -returnCodes error -result {wrong # args: should be "crimp table log ?max?"}

test crimp-table-12.1 {image tables, log} -body {
    crimp table log 0
} -returnCodes error -result {domain error: argument not in valid range}
# TODO: log, 0 out of range, better message

test crimp-table-12.2 {image tables, log} -body {
    crimp table log 1
    # near all white
} -result [concat 0 [lrepeat 255 255]]

test crimp-table-12.3 {image tables, log} -body {
    crimp table log 128
} -result {0 36 58 73 84 94 102 109 115 121 126 130 135 138 142 145 149 152 154 157 160 162 165 167 169 171 173 175 177 178 180 182 183 185 187 188 189 191 192 194 195 196 197 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 217 218 219 220 221 221 222 223 224 224 225 226 227 227 228 229 229 230 231 231 232 232 233 234 234 235 236 236 237 237 238 238 239 239 240 241 241 242 242 243 243 244 244 245 245 246 246 247 247 248 248 249 249 249 250 250 251 251 252 252 253 253 253 254 254 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255}

test crimp-table-12.4 {image tables, log} -body {
    crimp table log 254
} -result {0 32 51 64 74 82 90 96 101 106 110 114 118 121 125 128 130 133 135 138 140 142 144 146 148 150 152 153 155 157 158 159 161 162 164 165 166 167 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 184 185 186 187 188 188 189 190 191 191 192 193 193 194 195 196 196 197 197 198 199 199 200 200 201 202 202 203 203 204 204 205 206 206 207 207 208 208 209 209 210 210 211 211 211 212 212 213 213 214 214 215 215 215 216 216 217 217 218 218 218 219 219 220 220 220 221 221 221 222 222 223 223 223 224 224 224 225 225 225 226 226 226 227 227 227 228 228 228 229 229 229 230 230 230 231 231 231 231 232 232 232 233 233 233 234 234 234 234 235 235 235 236 236 236 236 237 237 237 237 238 238 238 238 239 239 239 239 240 240 240 240 241 241 241 241 242 242 242 242 243 243 243 243 244 244 244 244 245 245 245 245 245 246 246 246 246 247 247 247 247 247 248 248 248 248 248 249 249 249 249 249 250 250 250 250 250 251 251 251 251 251 252 252 252 252 252 253 253 253 253 253 254 254 254 254 254 254 255 255 255 255}

test crimp-table-12.5 {image tables, log} -body {
    crimp table log 255
} -result {0 32 51 64 74 82 89 96 101 106 110 114 118 121 125 128 130 133 135 138 140 142 144 146 148 150 152 153 155 156 158 159 161 162 163 165 166 167 168 170 171 172 173 174 175 176 177 178 179 180 181 182 183 183 184 185 186 187 188 188 189 190 191 191 192 193 193 194 195 195 196 197 197 198 199 199 200 200 201 202 202 203 203 204 204 205 205 206 206 207 207 208 208 209 209 210 210 211 211 212 212 213 213 214 214 214 215 215 216 216 217 217 217 218 218 219 219 219 220 220 221 221 221 222 222 222 223 223 223 224 224 225 225 225 226 226 226 227 227 227 228 228 228 229 229 229 229 230 230 230 231 231 231 232 232 232 233 233 233 233 234 234 234 235 235 235 235 236 236 236 236 237 237 237 238 238 238 238 239 239 239 239 240 240 240 240 241 241 241 241 242 242 242 242 242 243 243 243 243 244 244 244 244 245 245 245 245 245 246 246 246 246 247 247 247 247 247 248 248 248 248 248 249 249 249 249 249 250 250 250 250 250 251 251 251 251 251 252 252 252 252 252 253 253 253 253 253 254 254 254 254 254 254 255 255 255}

test crimp-table-12.6 {image tables, log} -body {
    crimp table log 256
} -result {0 32 50 64 74 82 89 96 101 106 110 114 118 121 124 127 130 133 135 138 140 142 144 146 148 150 151 153 155 156 158 159 161 162 163 165 166 167 168 170 171 172 173 174 175 176 177 178 179 180 181 182 182 183 184 185 186 187 187 188 189 190 190 191 192 193 193 194 195 195 196 197 197 198 198 199 200 200 201 201 202 203 203 204 204 205 205 206 206 207 207 208 208 209 209 210 210 211 211 212 212 213 213 213 214 214 215 215 216 216 216 217 217 218 218 218 219 219 220 220 220 221 221 222 222 222 223 223 223 224 224 224 225 225 225 226 226 226 227 227 227 228 228 228 229 229 229 230 230 230 231 231 231 231 232 232 232 233 233 233 234 234 234 234 235 235 235 235 236 236 236 237 237 237 237 238 238 238 238 239 239 239 239 240 240 240 240 241 241 241 241 242 242 242 242 243 243 243 243 243 244 244 244 244 245 245 245 245 245 246 246 246 246 247 247 247 247 247 248 248 248 248 248 249 249 249 249 249 250 250 250 250 250 251 251 251 251 251 252 252 252 252 252 253 253 253 253 253 254 254 254 254 254 254 255 255}

test crimp-table-12.6 {image tables, log} -body {
    crimp table log
} -result {0 32 51 64 74 82 89 96 101 106 110 114 118 121 125 128 130 133 135 138 140 142 144 146 148 150 152 153 155 156 158 159 161 162 163 165 166 167 168 170 171 172 173 174 175 176 177 178 179 180 181 182 183 183 184 185 186 187 188 188 189 190 191 191 192 193 193 194 195 195 196 197 197 198 199 199 200 200 201 202 202 203 203 204 204 205 205 206 206 207 207 208 208 209 209 210 210 211 211 212 212 213 213 214 214 214 215 215 216 216 217 217 217 218 218 219 219 219 220 220 221 221 221 222 222 222 223 223 223 224 224 225 225 225 226 226 226 227 227 227 228 228 228 229 229 229 229 230 230 230 231 231 231 232 232 232 233 233 233 233 234 234 234 235 235 235 235 236 236 236 236 237 237 237 238 238 238 238 239 239 239 239 240 240 240 240 241 241 241 241 242 242 242 242 242 243 243 243 243 244 244 244 244 245 245 245 245 245 246 246 246 246 247 247 247 247 247 248 248 248 248 248 249 249 249 249 249 250 250 250 250 250 251 251 251 251 251 252 252 252 252 252 253 253 253 253 253 254 254 254 254 254 254 255 255 255}

# -------------------------------------------------------------------------

test crimp-table-13.0 {image tables, linear, wrong\#args, not enough} -body {
    crimp table linear
} -returnCodes error -result {wrong # args: should be "crimp table linear subcommand ?argument ...?"}

test crimp-table-13.1 {image tables, linear, invalid method} -body {
    crimp table linear BOGUS
} -returnCodes error -result {unknown or ambiguous subcommand "BOGUS": must be clamp, or wrap}

# -------------------------------------------------------------------------

test crimp-table-14.0 {image tables, linear wrap, wrong\#args, not enough} -body {
    crimp table linear wrap
} -returnCodes error -result {wrong # args: should be "crimp table linear wrap gain offset"}

test crimp-table-14.1 {image tables, linear wrap, wrong\#args, not enough} -body {
    crimp table linear wrap GAIN
} -returnCodes error -result {wrong # args: should be "crimp table linear wrap gain offset"}

test crimp-table-14.2 {image tables, linear wrap, wrong\#args, too many} -body {
    crimp table linear wrap GAIN OFFSET bogus
} -returnCodes error -result {wrong # args: should be "crimp table linear wrap gain offset"}

# Compare to the 'linear clamp' next (table-15.x).

test crimp-table-14.3 {image tables, linear wrap} -body {
    crimp table linear wrap 0 0
    # staying in range, identical to 15.3
} -result [lrepeat 256 0]

test crimp-table-14.4 {image tables, linear wrap} -body {
    crimp table linear wrap 1 0
    # staying in range, identical to 15.4
} -result [iota 256]

test crimp-table-14.5 {image tables, linear wrap} -body {
    crimp table linear wrap 2 0
    # saw-tooth double frequency
} -result {0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 156 158 160 162 164 166 168 170 172 174 176 178 180 182 184 186 188 190 192 194 196 198 200 202 204 206 208 210 212 214 216 218 220 222 224 226 228 230 232 234 236 238 240 242 244 246 248 250 252 254 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177 179 181 183 185 187 189 191 193 195 197 199 201 203 205 207 209 211 213 215 217 219 221 223 225 227 229 231 233 235 237 239 241 243 245 247 249 251 253 255}

test crimp-table-14.6 {image tables, linear wrap} -body {
    crimp table linear wrap 0.5 0
    # saw-tooth half frequency, aka half-speed ramp, identical to 15.6
} -result {0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 54 54 55 55 56 56 57 57 58 58 59 59 60 60 61 61 62 62 63 63 64 64 65 65 66 66 67 67 68 68 69 69 70 70 71 71 72 72 73 73 74 74 75 75 76 76 77 77 78 78 79 79 80 80 81 81 82 82 83 83 84 84 85 85 86 86 87 87 88 88 89 89 90 90 91 91 92 92 93 93 94 94 95 95 96 96 97 97 98 98 99 99 100 100 101 101 102 102 103 103 104 104 105 105 106 106 107 107 108 108 109 109 110 110 111 111 112 112 113 113 114 114 115 115 116 116 117 117 118 118 119 119 120 120 121 121 122 122 123 123 124 124 125 125 126 126 127 127 128}

test crimp-table-14.7 {image tables, linear wrap} -body {
    crimp table linear wrap 1 10
    # horizontal rotate left
} -result {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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 1 2 3 4 5 6 7 8 9 10}

test crimp-table-14.8 {image tables, linear wrap} -body {
    crimp table linear wrap 1 -10
    # horizontal rotate left
} -result {245 246 247 248 249 250 251 252 253 254 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245}

# -------------------------------------------------------------------------

test crimp-table-15.0 {image tables, linear clamp, wrong\#args, not enough} -body {
    crimp table linear clamp
} -returnCodes error -result {wrong # args: should be "crimp table linear clamp gain offset"}

test crimp-table-15.1 {image tables, linear clamp, wrong\#args, not enough} -body {
    crimp table linear clamp GAIN
} -returnCodes error -result {wrong # args: should be "crimp table linear clamp gain offset"}

test crimp-table-15.2 {image tables, linear clamp, wrong\#args, too many} -body {
    crimp table linear clamp GAIN OFFSET bogus
} -returnCodes error -result {wrong # args: should be "crimp table linear clamp gain offset"}

# Compare to the 'linear clamp' previous (table-14.x).

test crimp-table-15.3 {image tables, linear clamp} -body {
    crimp table linear clamp 0 0
    # staying in range, identical to 14.3
} -result [lrepeat 256 0]

test crimp-table-15.4 {image tables, linear clamp} -body {
    crimp table linear clamp 1 0
    # staying in range, identical to 14.4
} -result [iota 256]

test crimp-table-15.5 {image tables, linear clamp} -body {
    crimp table linear clamp 2 0
    # double-speed ramp, clamped at white after
} -result {0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 156 158 160 162 164 166 168 170 172 174 176 178 180 182 184 186 188 190 192 194 196 198 200 202 204 206 208 210 212 214 216 218 220 222 224 226 228 230 232 234 236 238 240 242 244 246 248 250 252 254 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255}

test crimp-table-15.6 {image tables, linear clamp} -body {
    crimp table linear clamp 0.5 0
    # saw-tooth half frequency, aka half-speed ramp, identical to 14.6
} -result {0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 54 54 55 55 56 56 57 57 58 58 59 59 60 60 61 61 62 62 63 63 64 64 65 65 66 66 67 67 68 68 69 69 70 70 71 71 72 72 73 73 74 74 75 75 76 76 77 77 78 78 79 79 80 80 81 81 82 82 83 83 84 84 85 85 86 86 87 87 88 88 89 89 90 90 91 91 92 92 93 93 94 94 95 95 96 96 97 97 98 98 99 99 100 100 101 101 102 102 103 103 104 104 105 105 106 106 107 107 108 108 109 109 110 110 111 111 112 112 113 113 114 114 115 115 116 116 117 117 118 118 119 119 120 120 121 121 122 122 123 123 124 124 125 125 126 126 127 127 128}

test crimp-table-15.7 {image tables, linear clamp} -body {
    crimp table linear clamp 1 10
    # horizontal shift left, shifting in white at right
} -result {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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 255 255 255 255 255 255 255 255 255 255}

test crimp-table-15.8 {image tables, linear clamp} -body {
    crimp table linear clamp 1 -10
    # horizontal shift right, shifting in black at left
} -result {0 0 0 0 0 0 0 0 0 0 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245}

# -------------------------------------------------------------------------

test crimp-table-16.0 {image tables, stretch, wrong\#args, not enough} -body {
    crimp table stretch
} -returnCodes error -result {wrong # args: should be "crimp table stretch min max"}

test crimp-table-16.1 {image tables, stretch, wrong\#args, not enough} -body {
    crimp table stretch MIN
} -returnCodes error -result {wrong # args: should be "crimp table stretch min max"}

test crimp-table-16.2 {image tables, stretch, wrong\#args, too many} -body {
    crimp table stretch MIN MAX bogus
} -returnCodes error -result {wrong # args: should be "crimp table stretch min max"}

test crimp-table-16.3 {image tables, stretch} -body {
    crimp table stretch 0 255
} -result [iota 256]

test crimp-table-16.4 {image tables, stretch} -body {
    crimp table stretch 0 128
} -result {0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177 179 181 183 185 187 189 191 193 195 197 199 201 203 205 207 209 211 213 215 217 219 221 223 225 227 229 231 233 235 237 239 241 243 245 247 249 251 253 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255}

test crimp-table-16.5 {image tables, stretch} -body {
    crimp table stretch 128 255
} -result {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177 179 181 183 185 187 189 191 193 195 197 199 201 203 205 207 209 211 213 215 217 219 221 223 225 227 229 231 233 235 237 239 241 243 245 247 249 251 253 255}

test crimp-table-16.6 {image tables, stretch} -body {
    crimp table stretch 64 192
} -result {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177 179 181 183 185 187 189 191 193 195 197 199 201 203 205 207 209 211 213 215 217 219 221 223 225 227 229 231 233 235 237 239 241 243 245 247 249 251 253 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255}

test crimp-table-16.7 {image tables, stretch} -body {
    crimp table stretch -256 512
} -result {85 85 86 86 86 87 87 87 88 88 88 89 89 89 90 90 90 91 91 91 92 92 92 93 93 93 94 94 94 95 95 95 96 96 96 97 97 97 98 98 98 99 99 99 100 100 100 101 101 101 102 102 102 103 103 103 104 104 104 105 105 105 106 106 106 107 107 107 108 108 108 109 109 109 110 110 110 111 111 111 112 112 112 113 113 113 114 114 114 115 115 115 116 116 116 117 117 117 118 118 118 119 119 119 120 120 120 121 121 121 122 122 122 123 123 123 124 124 124 125 125 125 126 126 126 127 127 127 128 128 128 128 129 129 129 130 130 130 131 131 131 132 132 132 133 133 133 134 134 134 135 135 135 136 136 136 137 137 137 138 138 138 139 139 139 140 140 140 141 141 141 142 142 142 143 143 143 144 144 144 145 145 145 146 146 146 147 147 147 148 148 148 149 149 149 150 150 150 151 151 151 152 152 152 153 153 153 154 154 154 155 155 155 156 156 156 157 157 157 158 158 158 159 159 159 160 160 160 161 161 161 162 162 162 163 163 163 164 164 164 165 165 165 166 166 166 167 167 167 168 168 168 169 169 169 170}

test crimp-table-16.8 {image tables, stretch} -body {
    crimp table stretch 0 0
} -returnCodes error -result {domain error: argument not in valid range}
# TODO : stretch, vertical (min == max), better error message, or better handling.

test crimp-table-16.9 {image tables, stretch} -body {
    crimp table stretch 255 0
} -result [lreverse [iota 256]]

# -------------------------------------------------------------------------

test crimp-table-17.0 {image tables, threshold, wrong\#args, too many} -body {
    crimp table threshold
} -returnCodes error -result {wrong # args: should be "crimp table threshold subcommand ?argument ...?"}

test crimp-table-17.1 {image tables, threshold, invalid method} -body {
    crimp table threshold BOGUS
} -returnCodes error -result {unknown or ambiguous subcommand "BOGUS": must be above, below, inside, or outside}

# -------------------------------------------------------------------------

test crimp-table-18.0 {image tables, threshold above, wrong\#args, not enough} -body {
    crimp table threshold above
} -returnCodes error -result {wrong # args: should be "crimp table threshold above threshold"}

test crimp-table-18.1 {image tables, threshold above, wrong\#args, too many} -body {
    crimp table threshold above T bogus
} -returnCodes error -result {wrong # args: should be "crimp table threshold above threshold"}

test crimp-table-18.2 {image tables, threshold above} -body {
    crimp table threshold above -1
} -result [lrepeat 256 255]

test crimp-table-18.3 {image tables, threshold above} -body {
    crimp table threshold above 0
} -result [concat 0 [lrepeat 255 255]]

test crimp-table-18.4 {image tables, threshold above} -body {
    crimp table threshold above 1
} -result [concat {0 0} [lrepeat 254 255]]

test crimp-table-18.5 {image tables, threshold above} -body {
    crimp table threshold above 254
} -result [concat [lrepeat 255 0] 255]

test crimp-table-18.6 {image tables, threshold above} -body {
    crimp table threshold above 255
} -result [lrepeat 256 0]

test crimp-table-18.7 {image tables, threshold above} -body {
    crimp table threshold above 256
} -result [lrepeat 256 0]

# -------------------------------------------------------------------------

test crimp-table-19.0 {image tables, threshold below, wrong\#args, not enough} -body {
    crimp table threshold below
} -returnCodes error -result {wrong # args: should be "crimp table threshold below threshold"}

test crimp-table-19.1 {image tables, threshold below, wrong\#args, too many} -body {
    crimp table threshold below T bogus
} -returnCodes error -result {wrong # args: should be "crimp table threshold below threshold"}

test crimp-table-19.2 {image tables, threshold below} -body {
    crimp table threshold below -1
} -result [lrepeat 256 0]

test crimp-table-19.3 {image tables, threshold below} -body {
    crimp table threshold below 0
} -result [concat 255 [lrepeat 255 0]]

test crimp-table-19.4 {image tables, threshold below} -body {
    crimp table threshold below 1
} -result [concat {255 255} [lrepeat 254 0]]

test crimp-table-19.5 {image tables, threshold below} -body {
    crimp table threshold below 254
} -result [concat [lrepeat 255 255] 0]

test crimp-table-19.6 {image tables, threshold below} -body {
    crimp table threshold below 255
} -result [lrepeat 256 255]

test crimp-table-19.7 {image tables, threshold below} -body {
    crimp table threshold below 256
} -result [lrepeat 256 255]

# -------------------------------------------------------------------------

test crimp-table-20.0 {image tables, threshold inside, wrong\#args, not enough} -body {
    crimp table threshold inside
} -returnCodes error -result {wrong # args: should be "crimp table threshold inside min max"}

test crimp-table-20.1 {image tables, threshold inside, wrong\#args, not enough} -body {
    crimp table threshold inside MIN
} -returnCodes error -result {wrong # args: should be "crimp table threshold inside min max"}

test crimp-table-20.2 {image tables, threshold inside, wrong\#args, too many} -body {
    crimp table threshold inside MIN MAX bogus
} -returnCodes error -result {wrong # args: should be "crimp table threshold inside min max"}

test crimp-table-20.3 {image tables, threshold inside} -body {
    crimp table threshold inside -1 255
} -result [lrepeat 256 255]

test crimp-table-20.4 {image tables, threshold inside} -body {
    crimp table threshold inside 0 255
} -result [lrepeat 256 255]

test crimp-table-20.5 {image tables, threshold inside} -body {
    crimp table threshold inside 1 255
} -result [concat 0 [lrepeat 255 255]]

test crimp-table-20.6 {image tables, threshold inside} -body {
    crimp table threshold inside 254 255
} -result [concat [lrepeat 254 0] {255 255}]

test crimp-table-20.7 {image tables, threshold inside} -body {
    crimp table threshold inside 255 255
} -result [concat [lrepeat 255 0] 255]

test crimp-table-20.8 {image tables, threshold inside} -body {
    crimp table threshold inside 256 255
} -result [lrepeat 256 0]

# -------------------------------------------------------------------------

test crimp-table-21.0 {image tables, threshold outside, wrong\#args, not enough} -body {
    crimp table threshold outside
} -returnCodes error -result {wrong # args: should be "crimp table threshold outside min max"}

test crimp-table-21.1 {image tables, threshold outside, wrong\#args, not enough} -body {
    crimp table threshold outside MIN
} -returnCodes error -result {wrong # args: should be "crimp table threshold outside min max"}

test crimp-table-21.2 {image tables, threshold outside, wrong\#args, too many} -body {
    crimp table threshold outside MIN MAX bogus
} -returnCodes error -result {wrong # args: should be "crimp table threshold outside min max"}

test crimp-table-21.3 {image tables, threshold outside} -body {
    crimp table threshold outside -1 255
} -result [lrepeat 256 0]

test crimp-table-21.4 {image tables, threshold outside} -body {
    crimp table threshold outside 0 255
} -result [lrepeat 256 0]

test crimp-table-21.5 {image tables, threshold outside} -body {
    crimp table threshold outside 1 255
} -result [concat 255 [lrepeat 255 0]]

test crimp-table-21.6 {image tables, threshold outside} -body {
    crimp table threshold outside 254 255
} -result [concat [lrepeat 254 255] {0 0}]

test crimp-table-21.7 {image tables, threshold outside} -body {
    crimp table threshold outside 255 255
} -result [concat [lrepeat 255 255] 0]

test crimp-table-21.8 {image tables, threshold outside} -body {
    crimp table threshold outside 256 255
} -result [lrepeat 256 255]

# -------------------------------------------------------------------------

test crimp-table-22.0 {image tables, gauss, wrong\#args, not enough} -body {
    crimp table gauss
} -returnCodes error -result {wrong # args: should be "crimp table gauss sigma"}

test crimp-table-22.1 {image tables, gauss, wrong\#args, too many} -body {
    crimp table gauss SIGMA bogus
} -returnCodes error -result {wrong # args: should be "crimp table gauss sigma"}

test crimp-table-22.2 {image tables, gauss} -body {
    crimp table gauss 0.1
} -result [lrepeat 256 0]

test crimp-table-22.3 {image tables, gauss} -body {
    crimp table gauss 1
} -result {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 11 83 225 225 83 11 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}

test crimp-table-22.4 {image tables, gauss} -body {
    crimp table gauss 2
} -result {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 6 20 55 117 192 247 247 192 117 55 20 6 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}

test crimp-table-22.5 {image tables, gauss} -body {
    crimp table gauss 10
} -result {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 2 2 3 4 6 8 10 13 16 20 25 31 38 46 55 65 77 89 103 117 132 147 162 178 192 206 219 230 240 247 252 255 255 252 247 240 230 219 206 192 178 162 147 132 117 103 89 77 65 55 46 38 31 25 20 16 13 10 8 6 4 3 2 2 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}

# TODO: gauss (implementation): Allow for different mean values

# -------------------------------------------------------------------------
## fgauss breaks out of the mold of 256-entry tables, generating only
## as much as needed, and further producing floating point numbers.

test crimp-table-23.0 {image tables, fgauss, wrong\#args, not enough} -body {
    crimp table fgauss
} -returnCodes error -result {wrong # args: should be "crimp table fgauss subcommand ?argument ...?"}

test crimp-table-23.1 {image tables, fgauss, invalid method} -body {
    crimp table fgauss BOGUS
} -returnCodes error -result {unknown or ambiguous subcommand "BOGUS": must be discrete, or sampled}

# -------------------------------------------------------------------------

test crimp-table-24.0 {image tables, fgauss discrete, wrong\#args, not enough} -body {
    crimp table fgauss discrete
} -returnCodes error -result {wrong # args: should be "crimp table fgauss discrete sigma ?r?"}

test crimp-table-24.1 {image tables, fgauss discrete, wrong\#args, too many} -body {
    crimp table fgauss discrete SIGMA R bogus
} -returnCodes error -result {wrong # args: should be "crimp table fgauss discrete sigma ?r?"}

test crimp-table-24.2 {image tables, fgauss discrete} -body {
    lmap {format %.2f} [crimp table fgauss discrete 0.1]
} -result {0.00 0.99 0.00}

test crimp-table-24.3 {image tables, fgauss discrete} -body {
    lmap {format %.2f} [crimp table fgauss discrete 1]
} -result {0.01 0.05 0.21 0.47 0.21 0.05 0.01}

test crimp-table-24.4 {image tables, fgauss discrete} -body {
    lmap {format %.2f} [crimp table fgauss discrete 2]
} -result {0.00 0.01 0.03 0.06 0.12 0.18 0.21 0.18 0.12 0.06 0.03 0.01 0.00}

test crimp-table-24.5 {image tables, fgauss discrete} -body {
    lmap {format %.4f} [crimp table fgauss discrete 10]
} -result {0.0003 0.0004 0.0006 0.0008 0.0010 0.0013 0.0016 0.0021 0.0026 0.0032 0.0039 0.0048 0.0058 0.0070 0.0083 0.0097 0.0114 0.0132 0.0152 0.0174 0.0198 0.0224 0.0253 0.0284 0.0319 0.0357 0.0400 0.0449 0.0507 0.0575 0.0657 0.0575 0.0507 0.0449 0.0400 0.0357 0.0319 0.0284 0.0253 0.0224 0.0198 0.0174 0.0152 0.0132 0.0114 0.0097 0.0083 0.0070 0.0058 0.0048 0.0039 0.0032 0.0026 0.0021 0.0016 0.0013 0.0010 0.0008 0.0006 0.0004 0.0003}

# -------------------------------------------------------------------------

test crimp-table-25.0 {image tables, fgauss sampled, wrong\#args, not enough} -body {
    crimp table fgauss sampled
} -returnCodes error -result {wrong # args: should be "crimp table fgauss sampled sigma ?r?"}

test crimp-table-25.1 {image tables, fgauss sampled, wrong\#args, too many} -body {
    crimp table fgauss sampled SIGMA R bogus
} -returnCodes error -result {wrong # args: should be "crimp table fgauss sampled sigma ?r?"}

test crimp-table-25.2 {image tables, fgauss sampled} -body {
    lmap {format %.2f} [crimp table fgauss sampled 0.1]
} -result {0.00 1.00 0.00}

test crimp-table-25.3 {image tables, fgauss sampled} -body {
    lmap {format %.2f} [crimp table fgauss sampled 1]
} -result {0.01 0.04 0.30 0.30 0.30 0.04 0.01}

test crimp-table-25.4 {image tables, fgauss sampled} -body {
    lmap {format %.2f} [crimp table fgauss sampled 2]
} -result {0.00 0.01 0.02 0.06 0.16 0.16 0.16 0.16 0.16 0.06 0.02 0.01 0.00}

test crimp-table-25.5 {image tables, fgauss sampled} -body {
    lmap {format %.4f} [crimp table fgauss sampled 10]
} -result {0.0005 0.0005 0.0014 0.0014 0.0014 0.0014 0.0039 0.0039 0.0039 0.0039 0.0039 0.0107 0.0107 0.0107 0.0107 0.0107 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0290 0.0107 0.0107 0.0107 0.0107 0.0107 0.0039 0.0039 0.0039 0.0039 0.0039 0.0014 0.0014 0.0014 0.0014 0.0005 0.0005}

# -------------------------------------------------------------------------

test crimp-table-26.0 {image tables, quantize, wrong\#args, not enough} -body {
    crimp table quantize
} -returnCodes error -result {wrong # args: should be "crimp table quantize subcommand ?argument ...?"}

test crimp-table-26.1 {image tables, quantize, invalid method} -body {
    crimp table quantize BOGUS
} -returnCodes error -result {unknown or ambiguous subcommand "BOGUS": must be histogram}

# -------------------------------------------------------------------------

test crimp-table-27.0 {image tables, quantize histogram, wrong\#args, not enough} -body {
    crimp table quantize histogram
} -returnCodes error -result {wrong # args: should be "crimp table quantize histogram n p h"}

test crimp-table-27.1 {image tables, quantize histogram, wrong\#args, not enough} -body {
    crimp table quantize histogram N
} -returnCodes error -result {wrong # args: should be "crimp table quantize histogram n p h"}

test crimp-table-27.2 {image tables, quantize histogram, wrong\#args, not enough} -body {
    crimp table quantize histogram N P
} -returnCodes error -result {wrong # args: should be "crimp table quantize histogram n p h"}

test crimp-table-27.3 {image tables, quantize histogram, wrong\#args, too many} -body {
    crimp table quantize histogram N P H bogus
} -returnCodes error -result {wrong # args: should be "crimp table quantize histogram n p h"}

test crimp-table-27.4 {image tables, quantize histogram, invalid number of colors} -body {
    crimp table quantize histogram 1 P H
} -returnCodes error -result {Unable to calculate 1-color quantization}

# TODO: quant hist: percentile out of range 0-100, non-integer
# TODO: quant hist: bad histogram

# quantize histogram (n, p, h <==> #colors, percentile, histogram data)
# assert: #colors >= 2
# percentile special values
#   low, down, min =   0
#   median         =  50
#   high, up, max  = 100
# histogram data = dictionary (pixel value -> count)

test crimp-table-27.5 {image tables, quantize histogram} -setup {
    set h [dict get [crimp statistics basic [grey8]] channel luma histogram]
} -body {
    crimp table quantize histogram 2 min $h
} -cleanup {
    unset h
} -result {0 0 0 0 0 0 0 0 0 0 0 0 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128}

test crimp-table-27.6 {image tables, quantize histogram} -setup {
    set h [dict get [crimp statistics basic [grey8]] channel luma histogram]
} -body {
    crimp table quantize histogram 2 median $h
} -cleanup {
    unset h
} -result {64 64 64 64 64 64 64 64 64 64 64 64 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192}

test crimp-table-27.7 {image tables, quantize histogram} -setup {
    set h [dict get [crimp statistics basic [grey8]] channel luma histogram]
} -body {
    crimp table quantize histogram 2 max $h
} -cleanup {
    unset h
} -result {128 128 128 128 128 128 128 128 128 128 128 128 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255}

test crimp-table-27.8 {image tables, quantize histogram} -setup {
    set h [dict get [crimp statistics basic [grey8]] channel luma histogram]
} -body {
    crimp table quantize histogram 3 min $h
} -cleanup {
    unset h
} -result {0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170}

test crimp-table-27.9 {image tables, quantize histogram} -setup {
    set h [dict get [crimp statistics basic [grey8]] channel luma histogram]
} -body {
    crimp table quantize histogram 3 median $h
} -cleanup {
    unset h
} -result {43 43 43 43 43 43 43 43 128 128 128 128 128 128 128 128 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213 213}

test crimp-table-27.10 {image tables, quantize histogram} -setup {
    set h [dict get [crimp statistics basic [grey8]] channel luma histogram]
} -body {
    crimp table quantize histogram 3 max $h
} -cleanup {
    unset h
} -result {85 85 85 85 85 85 85 85 170 170 170 170 170 170 170 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255}

# -------------------------------------------------------------------------
testsuiteCleanup

# Local variables:
# mode: tcl
# indent-tabs-mode: nil
# End: