blob: d1a8a72cf0a2dde5eda2471a542c6a595c8f0e5b (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#! /bin/bash
# This script tests: pamslice pamdeinterlace
# Also requires: pamfile pamcut pamtopnm pamflip
echo "Test 1. Should print 139976034 137 twice"
# Slice rows, one by one, out of maze.pbm.
# Add header and reconstruct pbm image.
# Note that in pamslice output 0 is white and 1 is black: opposite of PBM
mwidth=$(pamfile -size maze.pbm | cut -d" " -f1)
height=16
pamcut -top=0 -left=0 -height=${height} maze.pbm | cksum
(echo "P1"
echo "${mwidth} ${height}"
for ((i = 0; i < ${height}; ++i))
do
pamslice -row=$i maze.pbm
done | cut -d" " -f2- | sed 'y/01/10/' ) \
| pamtopnm | cksum
echo "Test 2. Should print 1624460505 574 three times"
# Slice rows, one by one, out of ppm test image
# We take a part out of testimg.ppm with pamcut for processing the
# whole image takes much time.
# Add header and reconstruct ppm image.
tmpdir=${tmpdir:-/tmp}
test1711_ppm=${tmpdir}/test1711.ppm
pamcut -left=50 -top=50 -width=17 -height=11 testimg.ppm | \
tee ${test1711_ppm} | cksum
(echo "P3"
echo "17 11"
echo "255"
for ((i = 0; i < 11; ++i))
do
pamslice -row=$i ${test1711_ppm}
done | cut -d" " -f2- ) \
| pamtopnm | cksum
# Same as above test 2, but take cols instead of rows.
# Should print 914327477 4864
(echo "P3"
echo "11 17"
echo "255"
for ((i = 0; i < 17; ++i))
do
pamslice -col=$i ${test1711_ppm}
done | cut -d " " -f2- ) | pamflip -xy | cksum
echo "Test 3. Should print 1624460505 574"
# Divide input image into two with pamdeinterlace and recombine.
testeven_ppm=${tmpdir}/testeven.ppm
testodd_ppm=${tmpdir}/testodd.ppm
pamdeinterlace -takeodd ${test1711_ppm} > ${testodd_ppm}
pamdeinterlace -takeeven ${test1711_ppm} > ${testeven_ppm}
( echo "P3"
echo "17 11"
echo "255"
( for ((i = 0; i < 5; ++i))
do
pamslice -row=$i ${testeven_ppm}
pamslice -row=$i ${testodd_ppm}
done
pamslice -row=5 ${testeven_ppm};
) | cut -d" " -f2- ) | pamtopnm | cksum
rm ${test1711_ppm} ${testodd_ppm} ${testeven_ppm}
|