#!/bin/bash

# 

SOURCE='C.tga'
NBR_FRAMES=19
K=$(( 10000 / NBR_FRAMES ))
T_CDR="48 160"

# ------ traitements de l'image source
dstA=/tmp/dstA.tga
dstB=/tmp/dstB.tga
dstC=/tmp/dstC.tga
dstD=/tmp/dstD.tga

export TGA_OUTILS_VERBOSE="yes"

tga_effects $SOURCE seuil $dstA 64 128 192
tga_equalize $dstA lumin $dstA 130

tga_equalize $SOURCE std $dstB
tga_effects $dstB flatgray $dstB 128

tga_filtres $SOURCE lopass $dstC
tga_effects $dstC cont2x2    $dstC

# animate -delay 100 /tmp/dst*.tga &

numimg=0

for frame in $(seq 0 $NBR_FRAMES)
do
	numimg=$(( numimg + 1 ))
	oname=/tmp/mixanim$(printf %03d $numimg).tga
	k=$(( frame * K ))
	tga_combine $dstB $dstA mix_gray $oname $k
	tga_cadre $oname filetg $oname $T_CDR
	msg=$(printf "A->B %3d %5d " $numimg $k)
	# tga_tools message $oname 0 "$msg"
done

for frame in $(seq 0 $NBR_FRAMES)
do
	numimg=$(( numimg + 1 ))
	oname=/tmp/mixanim$(printf %03d $numimg).tga
	k=$(( frame * K ))
	tga_combine $dstC $dstB mix_gray $oname $k
	tga_cadre $oname filetg $oname $T_CDR
	msg=$(printf "B->C %3d %5d " $numimg $k)
	# tga_tools message $oname 0 "$msg"
done


for frame in $(seq 0 $NBR_FRAMES)
do
	numimg=$(( numimg + 1 ))
	oname=/tmp/mixanim$(printf %03d $numimg).tga
	k=$(( frame * K ))
	tga_combine $dstA $dstC mix_gray $oname $k
	tga_cadre $oname filetg $oname $T_CDR
	msg=$(printf "C->A %3d %5d " $numimg $k)
	# tga_tools message $oname 0 "$msg"
done

set -v

convert -delay 10 /tmp/mixanim*.tga mixanim.gif

