|
shun-iwasawa |
82a8f5 |
#!/bin/bash
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
set -u
|
|
shun-iwasawa |
82a8f5 |
set -e
|
|
shun-iwasawa |
82a8f5 |
trap onexit INT
|
|
shun-iwasawa |
82a8f5 |
trap onexit TERM
|
|
shun-iwasawa |
82a8f5 |
trap onexit EXIT
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
onexit()
|
|
shun-iwasawa |
82a8f5 |
{
|
|
shun-iwasawa |
82a8f5 |
if [ -d $OUTDIR ]; then
|
|
shun-iwasawa |
82a8f5 |
rm -rf $OUTDIR
|
|
shun-iwasawa |
82a8f5 |
fi
|
|
shun-iwasawa |
82a8f5 |
}
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
runme()
|
|
shun-iwasawa |
82a8f5 |
{
|
|
shun-iwasawa |
82a8f5 |
echo \*\*\* $*
|
|
shun-iwasawa |
82a8f5 |
"$@"
|
|
shun-iwasawa |
82a8f5 |
}
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
IMAGES="vgl_5674_0098.bmp vgl_6434_0018a.bmp vgl_6548_0026a.bmp nightshot_iso_100.bmp"
|
|
shun-iwasawa |
82a8f5 |
IMGDIR=@CMAKE_CURRENT_SOURCE_DIR@/testimages
|
|
shun-iwasawa |
82a8f5 |
OUTDIR=`mktemp -d /tmp/__tjexampletest_java_output.XXXXXX`
|
|
shun-iwasawa |
82a8f5 |
EXEDIR=@CMAKE_CURRENT_BINARY_DIR@
|
|
shun-iwasawa |
82a8f5 |
JAVA="@Java_JAVA_EXECUTABLE@"
|
|
shun-iwasawa |
82a8f5 |
JAVAARGS="-cp $EXEDIR/java/turbojpeg.jar -Djava.library.path=$EXEDIR"
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
if [ -d $OUTDIR ]; then
|
|
shun-iwasawa |
82a8f5 |
rm -rf $OUTDIR
|
|
shun-iwasawa |
82a8f5 |
fi
|
|
shun-iwasawa |
82a8f5 |
mkdir -p $OUTDIR
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
exec >$EXEDIR/tjexampletest-java.log
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
for image in $IMAGES; do
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
cp $IMGDIR/$image $OUTDIR
|
|
shun-iwasawa |
82a8f5 |
basename=`basename $image .bmp`
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/cjpeg -quality 95 -dct fast -grayscale -outfile $OUTDIR/${basename}_GRAY_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 -outfile $OUTDIR/${basename}_420_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 -outfile $OUTDIR/${basename}_422_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 -outfile $OUTDIR/${basename}_444_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/cjpeg -quality 95 -dct int -grayscale -outfile $OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 -outfile $OUTDIR/${basename}_420_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 -outfile $OUTDIR/${basename}_422_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 -outfile $OUTDIR/${basename}_444_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
|
|
shun-iwasawa |
82a8f5 |
for samp in GRAY 420 422 444; do
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/djpeg -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_default_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/djpeg -dct fast -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_fast_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/djpeg -dct int -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
for samp in 420 422; do
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/djpeg -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/djpeg -dct fast -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/djpeg -dct int -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
# Compression
|
|
shun-iwasawa |
82a8f5 |
for dct in fast accurate; do
|
|
shun-iwasawa |
82a8f5 |
for samp in GRAY 420 422 444; do
|
|
shun-iwasawa |
82a8f5 |
runme "$JAVA" $JAVAARGS TJExample $OUTDIR/$image $OUTDIR/${basename}_${samp}_${dct}.jpg -q 95 -subsamp ${samp} -${dct}dct
|
|
shun-iwasawa |
82a8f5 |
runme cmp $OUTDIR/${basename}_${samp}_${dct}.jpg $OUTDIR/${basename}_${samp}_${dct}_cjpeg.jpg
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
# Decompression
|
|
shun-iwasawa |
82a8f5 |
for dct in fast accurate default; do
|
|
shun-iwasawa |
82a8f5 |
srcdct=${dct}
|
|
shun-iwasawa |
82a8f5 |
dctarg=-${dct}dct
|
|
shun-iwasawa |
82a8f5 |
if [ "${dct}" = "default" ]; then
|
|
shun-iwasawa |
82a8f5 |
srcdct=fast
|
|
shun-iwasawa |
82a8f5 |
dctarg=
|
|
shun-iwasawa |
82a8f5 |
fi
|
|
shun-iwasawa |
82a8f5 |
for samp in GRAY 420 422 444; do
|
|
shun-iwasawa |
82a8f5 |
runme "$JAVA" $JAVAARGS TJExample $OUTDIR/${basename}_${samp}_${srcdct}.jpg $OUTDIR/${basename}_${samp}_${dct}.bmp ${dctarg}
|
|
shun-iwasawa |
82a8f5 |
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${dct}.bmp $OUTDIR/${basename}_${samp}_${dct}_djpeg.bmp
|
|
shun-iwasawa |
82a8f5 |
rm $OUTDIR/${basename}_${samp}_${dct}.bmp
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
for samp in 420 422; do
|
|
shun-iwasawa |
82a8f5 |
runme "$JAVA" $JAVAARGS TJExample $OUTDIR/${basename}_${samp}_${srcdct}.jpg $OUTDIR/${basename}_${samp}_${dct}_nosmooth.bmp -fastupsample ${dctarg}
|
|
shun-iwasawa |
82a8f5 |
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${dct}_nosmooth.bmp $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.bmp
|
|
shun-iwasawa |
82a8f5 |
rm $OUTDIR/${basename}_${samp}_${dct}_nosmooth.bmp
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
# Scaled decompression
|
|
shun-iwasawa |
82a8f5 |
for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do
|
|
shun-iwasawa |
82a8f5 |
scalearg=`echo $scale | sed 's/\_/\//g'`
|
|
shun-iwasawa |
82a8f5 |
for samp in GRAY 420 422 444; do
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/djpeg -rgb -bmp -scale ${scalearg} -outfile $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
|
|
shun-iwasawa |
82a8f5 |
runme "$JAVA" $JAVAARGS TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${scale}.bmp -scale ${scalearg}
|
|
shun-iwasawa |
82a8f5 |
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${scale}.bmp $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp
|
|
shun-iwasawa |
82a8f5 |
rm $OUTDIR/${basename}_${samp}_${scale}.bmp
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
# Transforms
|
|
shun-iwasawa |
82a8f5 |
for samp in GRAY 420 422 444; do
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/jpegtran -crop 70x60+16+16 -flip horizontal -trim -outfile $OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/jpegtran -crop 70x60+16+16 -flip vertical -trim -outfile $OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/jpegtran -crop 70x60+16+16 -transpose -trim -outfile $OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/jpegtran -crop 70x60+16+16 -transverse -trim -outfile $OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/jpegtran -crop 70x60+16+16 -rotate 90 -trim -outfile $OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/jpegtran -crop 70x60+16+16 -rotate 180 -trim -outfile $OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/jpegtran -crop 70x60+16+16 -rotate 270 -trim -outfile $OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
|
|
shun-iwasawa |
82a8f5 |
for samp in GRAY 420 422 444; do
|
|
shun-iwasawa |
82a8f5 |
runme "$JAVA" $JAVAARGS TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.jpg -$xform -crop 70x60+16+16
|
|
shun-iwasawa |
82a8f5 |
runme cmp $OUTDIR/${basename}_${samp}_${xform}.jpg $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/djpeg -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
|
|
shun-iwasawa |
82a8f5 |
runme "$JAVA" $JAVAARGS TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.bmp -$xform -crop 70x60+16+16
|
|
shun-iwasawa |
82a8f5 |
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
|
|
shun-iwasawa |
82a8f5 |
rm $OUTDIR/${basename}_${samp}_${xform}.bmp
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
for samp in 420 422; do
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/djpeg -nosmooth -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
|
|
shun-iwasawa |
82a8f5 |
runme "$JAVA" $JAVAARGS TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.bmp -$xform -crop 70x60+16+16 -fastupsample
|
|
shun-iwasawa |
82a8f5 |
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
|
|
shun-iwasawa |
82a8f5 |
rm $OUTDIR/${basename}_${samp}_${xform}.bmp
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
# Grayscale transform
|
|
shun-iwasawa |
82a8f5 |
for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
|
|
shun-iwasawa |
82a8f5 |
for samp in GRAY 444 422 420; do
|
|
shun-iwasawa |
82a8f5 |
runme "$JAVA" $JAVAARGS TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.jpg -$xform -grayscale -crop 70x60+16+16
|
|
shun-iwasawa |
82a8f5 |
runme cmp $OUTDIR/${basename}_${samp}_${xform}.jpg $OUTDIR/${basename}_GRAY_${xform}_jpegtran.jpg
|
|
shun-iwasawa |
82a8f5 |
runme "$JAVA" $JAVAARGS TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.bmp -$xform -grayscale -crop 70x60+16+16
|
|
shun-iwasawa |
82a8f5 |
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}.bmp $OUTDIR/${basename}_GRAY_${xform}_jpegtran.bmp
|
|
shun-iwasawa |
82a8f5 |
rm $OUTDIR/${basename}_${samp}_${xform}.bmp
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
# Transforms with scaling
|
|
shun-iwasawa |
82a8f5 |
for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
|
|
shun-iwasawa |
82a8f5 |
for samp in GRAY 444 422 420; do
|
|
shun-iwasawa |
82a8f5 |
for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do
|
|
shun-iwasawa |
82a8f5 |
scalearg=`echo $scale | sed 's/\_/\//g'`
|
|
shun-iwasawa |
82a8f5 |
runme $EXEDIR/djpeg -rgb -bmp -scale ${scalearg} -outfile $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
|
|
shun-iwasawa |
82a8f5 |
runme "$JAVA" $JAVAARGS TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}_${scale}.bmp -$xform -scale ${scalearg} -crop 70x60+16+16
|
|
shun-iwasawa |
82a8f5 |
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}_${scale}.bmp $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp
|
|
shun-iwasawa |
82a8f5 |
rm $OUTDIR/${basename}_${samp}_${xform}_${scale}.bmp
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
done
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
echo SUCCESS!
|