-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswapFFT
executable file
·40 lines (31 loc) · 984 Bytes
/
swapFFT
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
#!/bin/bash
# Do a FFT transform of two pictures, then transform them back
# swapping the phase information
if [ "$#" -lt 6 ]; then
echo 'USAGE: swapFFT PICFILE1 PICFILE2 OUT1 OUT2 OUT3 OUT4'
exit 65
fi
PICFILE1=$1
PIC1=${PICFILE1%.*}
PICFILE2=$2
PIC2=${PICFILE2%.*}
OUT1=$3
OUT2=$4
OUT3=$5
OUT4=$6
echo "Going to swap "$PICFILE1" and "$PICFILE2
convert $PICFILE1 -fft $PIC1"_fft.png"
convert $PICFILE2 -fft $PIC2"_fft.png"
convert $PIC1"_fft-0.png" $PIC2"_fft-1.png" -ift $OUT1".jpg"
convert $PIC2"_fft-0.png" $PIC1"_fft-1.png" -ift $OUT2".jpg"
convert $OUT1".jpg" $OUT2".jpg" +append $OUT3".jpg"
convert $PICFILE1 $PICFILE2 +append $OUTNAME"_input.jpg"
convert $OUTNAME"_input.jpg" $OUT3".jpg" -append $OUT4".jpg"
rm $PIC1"_fft-"*".png"
rm $PIC2"_fft-"*".png"
rm $OUTNAME"_input.jpg"
echo ""
echo "First swap: "$OUT1".jpg"
echo "Second swap: "$OUT2".jpg"
echo "Side by side comparison (outputs): "$OUT3".jpg"
echo "Side by side comparison (w/ inputs): "$OUT4".jpg"