about summary refs log tree commit diff
path: root/test/ppmmix.test
blob: d24e589da354daaef99036e10f60cbbd315f31f9 (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
#! /bin/bash
# This script tests: ppmmix
# Also requires: pamdepth pamenlarge pamsumm pbmmake
# Also requires: pgmtopgm pnminvert ppmtopgm

  alias ppmmix="${PBM_TESTPREFIX}ppmmix"
  alias pamdepth="${PBM_BINPREFIX}pamdepth"
  alias pamenlarge="${PBM_BINPREFIX}pamenlarge"
  alias pamsumm="${PBM_BINPREFIX}pamsumm"
  alias pbmmake="${PBM_BINPREFIX}pbmmake"
  alias pgmtopgm="${PBM_BINPREFIX}pgmtopgm"
  alias pnminvert="${PBM_BINPREFIX}pnminvert"
  alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm"
  shopt -s expand_aliases

# Print a pretty checkerboard pattern
pbmmake -g 8 8 | \
 pgmtopgm > ${tmpdir}/a1.pgm &&
pbmmake -g 2 2 | pamenlarge 4 | \
 pgmtopgm > ${tmpdir}/a2.pgm &&
ppmmix 0.75 ${tmpdir}/a1.pgm ${tmpdir}/a2.pgm -plain | \
 ppmtopgm | pamdepth 3 -plain &&
rm ${tmpdir}/a1.pgm ${tmpdir}/a2.pgm

# Mix image with itself.
# Output should match input regardless of ratio. 
for i in 0 0.5 0.6 1
do 
ppmmix $i testimg.ppm testimg.ppm | cksum
done

# Mix image with its own inverse.
# Output should be a monotone gray sheet.
pnminvert testimg.ppm | ppmmix .5 \
    testimg.ppm - | tee ${tmpdir}/a3.ppm | \
  pamsumm -brief -max &&
  pamsumm -brief -min ${tmpdir}/a3.ppm &&
rm ${tmpdir}/a3.ppm