#!/bin/sh
# ----------------------------------------------------------------------
#    SparseLab1.1 benchmark
#    Test image decomposition and inpainting using MCA solver.

IMAGE=../../data/tg128x128.pan
IMASKED=../../data/tg128x128_masked.pan
IMASK=../../data/mask_128x128_brush.pan

clear

echo "----------------------------------------------------------------------"
echo "   SparseLab1.1 benchmark"
echo "   Test image decomposition and inpainting using MCA solver."


# ----------------------------------------------------------------------
#     Dictionary specifications: two transforms for this example.

echo
echo "   UDWT transform (natural smooth part)"
echo "   For UDWT, specify a QMF"
echo "   ../../bin/qmf symmlet 6 qmf.col"
../../bin/qmf symmlet 6 qmf.col
echo "   Make first transform of the dictionary"
echo "   ../../bin/dictionary UDWT 5 qmf.col 0 dict_tg.col dict_tg.col"
../../bin/dictionary UDWT 5 qmf.col 0 dict_tg.col dict_tg.col

echo
echo "   LDCT transform (textured locally oscillatory part)"
echo "   Make second transform of the dictionary"
echo "   ../../bin/dictionary LDCT 16 0 0 dict_tg.col dict_tg.col"
../../bin/dictionary LDCT 16 0 0 dict_tg.col dict_tg.col



# ----------------------------------------------------------------------
#     Apply MCA.

echo
echo "----------------------------------------------------------------------"
echo "  Apply MCA."
echo "  ../../bin/mca 50 1 0.05 0 0 dict_tg.col $IMAGE mca_test.pan"
../../bin/mca 50 1 0.05 0 0 dict_tg.col $IMAGE mca_test.pan



# ----------------------------------------------------------------------
#     Inpainting.

echo
echo "----------------------------------------------------------------------"
echo "  Inpainting: ECM with fixed lambda."
echo "  ../../bin/eminpaint 1 1E-6 3 0.2 1 0 dict_tg.col $IMASKED $IMASK inpaint_test_ecm1.pan"
../../bin/eminpaint 1 1E-6 3 0.2 1 0 dict_tg.col $IMASKED $IMASK inpaint_test_ecm1.pan

echo
echo "----------------------------------------------------------------------"
echo "  Inpainting: ECM with varying lambda (MCA)."
echo "  ../../bin/eminpaint 50 1E-6 0 1 1 2 dict_tg.col $IMASKED $IMASK inpaint_test_ecm2.pan"
../../bin/eminpaint 50 1E-6 0 1 1 2 dict_tg.col $IMASKED $IMASK inpaint_test_ecm2.pan



# ----------------------------------------------------------------------
#     Clean up temporary storage.

echo
echo "   Clean up."
rm qmf.col dict_tg.col

echo
