about summary refs log tree commit diff
path: root/test/ppmchange.test
blob: 039a4a81f59f48f642a80fcefbf4ce9e70534674 (plain) (blame)
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
#! /bin/sh
# This script tests: ppmchange
# Also requires: ppmrainbow pgmramp ppmhist

#  Failure message
## If this test fails and ppmchange-roundtrip.test succeeds,
## the probable cause is a problem with one of the options of
## ppmchange: -closeness or -remainder.

tmpdir=${tmpdir:-/tmp}
rainbow_ppm="${tmpdir}"/rainbow.ppm
changed_ppm="${tmpdir}"/changed.ppm

RGBDEF=./rgbt.txt

gray=rgb:7f/7f/7f

# Test 1. Should print 22488533 203
pgmramp -lr 8 8 | ppmchange black black  white white ${gray} ${gray} \
  -close=10 -remainder=blue | cksum


# Test 2. Should print 1008787190 613

ppmrainbow -tmpdir="${tmpdir}" -width=200 -height=1 red green blue | \
  tee ${rainbow_ppm} | \
  ppmchange red brown   green brown   blue brown | cksum

# Validate ${rainbow_ppm}
# Should print 1983174784 613

cat ${rainbow_ppm} | cksum

# Test 3. Should print 2146447222 613

ppmchange red brown   green cyan   blue yellow \
  -closeness=25 ${rainbow_ppm} | cksum


# Test 4. Should print 1216791938 613

ppmchange red rgb:64/00/01 rgb:00/ff/00 rgb:00/32/02 blue blue \
  -remainder=black -closeness=25 ${rainbow_ppm} | tee ${changed_ppm} | cksum

# Produce a histogram of the colors in the output image
# Should produce
#     0     0     0	    0	     78 
#     0     0   255	   29	     40 
#     0    50     2	   30	     41 
#   100     0     1	   30	     41 

ppmhist -sort=rgb -noheader ${changed_ppm}


rm ${rainbow_ppm} ${changed_ppm}