about summary refs log tree commit diff
path: root/test/ppmmix.test
blob: 9a54143ffc05ab614d47518e7a1ad4335faee6c0 (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
#! /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

tmpdir=${tmpdir:-/tmp}

# Test 1. Print a pretty checkerboard pattern
a1_pgm=${tmpdir}/a1.pgm
a2_pgm=${tmpdir}/a2.pgm

pbmmake -g 8 8 | pgmtopgm > ${a1_pgm} &&
pbmmake -g 2 2 | pamenlarge 4 | pgmtopgm > ${a2_pgm} &&
ppmmix 0.75 ${a1_pgm} ${a2_pgm} | ppmtopgm | pamdepth 3 -plain &&
rm ${a1_pgm} ${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.
a3_ppm=${tmpdir}/a3.ppm

pnminvert testimg.ppm | ppmmix .5 \
    testimg.ppm - | tee ${a3_ppm} | \
  pamsumm -brief -max &&
  pamsumm -brief -min ${a3_ppm} &&
rm ${a3_ppm}