#! /bin/sh
#
# SparseLab Pandore toolbox
#
# GREYC IMAGE
# 6 Boulevard Marechal Juin
# F-14050 Caen Cedex
#
# Please to email any bugs, comments, and/or additions to this file see:
# http://www.greyc.ensicaen.fr/EquipeImage/Pandore
#
#(C) Jalal Fadili - 2007-05-31
#
# Nonlinear approximation capabilities of the wave atom transform.

echo ----------------------------------------------------------------
echo 'Seismic image : keep the first 1536 largest coeffs in magnitude' 
echo '(the equivalent threshold was pre-computed).'
echo ----------------------------------------------------------------
imin=../../data/seismic.pan
thd=34.2176
realmax=1.7977e+308

# Display input image.
pvisu $imin

# Forward transform.
echo 'Forward transform'
../../bin/fatomfm2sym p $imin c.pan

# Keep largest coefficients in magnitude.
echo Keep largest coefficients in magnitude.
pabs c.pan cabs.pan
pbinarization $thd $realmax cabs.pan mask.pan
pmask c.pan mask.pan cmasked.pan

# Inverse transform.
echo 'Inverse transform'
../../bin/iatomfm2sym p cmasked.pan rec.pan
pvisu rec.pan

# Display PSNR.
pmaximumvalue $imin
max=`pstatus`
ppsnr $max $imin rec.pan
psnr=`pstatus`
echo Reconstruction PSNR from 1536 coeffs '(0.29%)' is $psnr dB 

echo -------------------------------------------------------------------
echo 'Fingerprint image : keep the first 512 largest coeffs in magnitude'
echo '(the equivalent threshold was pre-computed).'
echo -------------------------------------------------------------------
imin=../../data/fingerprint.pan
thd=224.7631
realmax=1.7977e+308

# Display input image.
pvisu $imin

# Forward transform.
echo 'Forward transform'
../../bin/fatomfm2sym p $imin c.pan

# Keep largest coefficients in magnitude.
echo Keep largest coefficients in magnitude.
pabs c.pan cabs.pan
pbinarization $thd $realmax cabs.pan mask.pan
pmask c.pan mask.pan cmasked.pan

# Inverse transform.
echo 'Inverse transform'
../../bin/iatomfm2sym p cmasked.pan rec.pan
pvisu rec.pan

# Display PSNR.
pmaximumvalue $imin
max=`pstatus`
ppsnr $max $imin rec.pan
psnr=`pstatus`
echo Reconstruction PSNR from 512 coeffs '(0.1%)' is $psnr dB 

rm {c,cabs,cmasked,mask,rec}.pan
