-
Notifications
You must be signed in to change notification settings - Fork 0
/
Demo_SRCNN3D_RegSS.sh
62 lines (49 loc) · 1.76 KB
/
Demo_SRCNN3D_RegSS.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# This script executes a DEMO for the RegSS-SRCNN3D method
# Author:
# Karl Thurnhofer Hemsi
# Department of Computer Languages and Computer Sciences
# University of Málaga (Spain)
SRCNN3D_Path=../../../SRCNN3D
ImagesPath=./Images
RegSSImagesPath=./RegSSImages
SRImagesPath=./SR_RegSSImages
ZoomFactor=2
FICHEROS=`find $ImagesPath/*.nii -maxdepth 0`
for fich in $FICHEROS;
do
path=${fich%/*}
file=${fich##*/}
base=${file%%.*}
echo "Processing image: ${base}"
# Downsample HR image to obtain a LR image (if it is available)
if [[ ${base} != *"_LR"* ]]; then
suffix='_LR'
matlab -nojvm -nodisplay -nosplash -r "HR2LR('$fich',$ZoomFactor); exit();"
else
suffix=''
fi
# Create regular shifts for this image
mkdir -p $RegSSImagesPath
matlab -nojvm -nodisplay -nosplash -r "CreateRegularShifts('${path}/${base}${suffix}.nii','$RegSSImagesPath'); exit();"
# Define SRCNN model path
NumStepsModel=470000
TestPath=${SRCNN3D_Path}/Test
Model=${TestPath}/caffe_model/Iter_${NumStepsModel}
# Create results directory
mkdir -p $SRImagesPath
# Execute a loop to store the SRCNN3D input
SUBFICHEROS=`dir $RegSSImagesPath/${base}*.nii`
ENTRADA=''
for subfich in $SUBFICHEROS;
do
subfile=${subfich##*/}
subbase=${subfile%%.*}
ENTRADA="${ENTRADA} -t ${subfich} -r ${SRImagesPath}/${subbase}_SRCNN3D.nii"
done
# Run the SRCNN3D
echo "Performing SRCNN3D tests"
python ${TestPath}/demo_SRCNN3D.py $ENTRADA -m ${Model}/SRCNN3D_iter_${NumStepsModel}.caffemodel -n ${Model}/SRCNN3D_deploy.prototxt -g True -s "${ZoomFactor},${ZoomFactor},${ZoomFactor}"
# Reconstruct final image using upsampled shifted images
matlab -nojvm -nodisplay -nosplash -r "ReconstructImages('${path}','${base}','$RegSSImagesPath','${SRImagesPath}',${ZoomFactor}); exit();"
done