Browse Source

Merge branch 'release/v0.0.9'

Jérôme BUISINE 3 months ago
parent
commit
762b176e1a

+ 4 - 1
main/rawls_merge_mean.cpp

@@ -27,6 +27,7 @@ int main(int argc, char *argv[]){
     std::string folderName;
     std::string outfileName;
     unsigned nbSamples = 10;
+    unsigned startIndex = 0;
     bool random;
 
     for (int i = 1; i < argc; ++i) {
@@ -38,6 +39,8 @@ int main(int argc, char *argv[]){
             random = bool(atoi(argv[++i]));
         }else if (!strcmp(argv[i], "--outfile") || !strcmp(argv[i], "-ouftile")) {
             outfileName = argv[++i];
+        }else if (!strcmp(argv[i], "--startindex") || !strcmp(argv[i], "-startindex")) {
+            startIndex = atoi(argv[++i]);
         }
     }
 
@@ -90,7 +93,7 @@ int main(int argc, char *argv[]){
     float progress = 0.0;
     unsigned bufferSize = width * height * nbChanels;
 
-    for (unsigned i = 0; i < nbSamples; i++){
+    for (unsigned i = startIndex; i < (nbSamples + startIndex); i++){
 
         // read into folder all `.rawls` file and merge pixels values
         float* buffer = rawls::getPixelsRAWLS(imagesPath.at(i));

+ 63 - 0
run/compare_folder.sh

@@ -0,0 +1,63 @@
+if [ -z "$1" ]
+  then
+    echo "No argument supplied"
+    echo "Folder with images to compare"
+    exit 1
+fi
+
+if [ -z "$2" ]
+  then
+    echo "No argument supplied"
+    echo "Expected metric choice"
+    exit 1
+fi
+
+if [ -z "$3" ]
+  then
+    echo "No argument supplied"
+    echo "Output markdown filename"
+    exit 1
+fi
+
+folder_path=$1
+metric=$2
+markdown_file=$3
+
+
+header_line="# | "
+for image in $(ls ${folder_path}/)
+do
+    IFS='.' read -ra ADDR <<< "${image}"
+    image_name=${ADDR[0]}
+
+    IFS='_' read -ra ADDR <<< "${image_name}"
+    image_index=${ADDR[-1]}
+
+    header_line="${header_line} ${image_index} |"
+done
+
+echo $folder_path > $markdown_file
+echo ""
+echo ${header_line} >> $markdown_file
+
+for image_i in $(ls ${folder_path}/)
+do
+    IFS='.' read -ra ADDR <<< "${image_i}"
+    image_i_name=${ADDR[0]}
+
+    IFS='_' read -ra ADDR <<< "${image_i_name}"
+    image_i_index=${ADDR[-1]}
+
+
+    line="${image_i_index} | "
+    
+    for image_j in $(ls ${folder_path}/)
+    do
+        echo "Comparisons between ${image_i} and ${image_j}"
+        estimated_error=$(python utils/compare_images.py --img1 ${folder_path}/${image_i} --img2 ${folder_path}/${image_j} --metric ${metric})
+        line="${line} ${estimated_error} | "
+    done
+
+    echo ${line} >> $markdown_file
+done
+

convert_folder.sh → run/convert_folder.sh


reconstruct_png.sh → run/reconstruct_png.sh


reconstruct_png_mon.sh → run/reconstruct_png_mon.sh


+ 52 - 0
run/reconstruct_png_step.sh

@@ -0,0 +1,52 @@
+#! /bin/bash
+
+if [ -z "$1" ]
+  then
+    echo "No argument supplied"
+    echo "Need data folder"
+    exit 1
+fi
+
+if [ -z "$2" ]
+  then
+    echo "No argument supplied"
+    echo "Need output folder"
+    exit 1
+fi
+
+if [ -z "$3" ]
+  then
+    echo "No argument supplied"
+    echo "Need step output images expected (step of samples)"
+    exit 1
+fi
+
+prefix="p3d_"
+build_folder="build"
+
+folder_path=$1
+output_folder=$2
+step=$3
+
+nb_elements=$(ls -l ${folder_path} | grep ${prefix} | wc -l)
+
+IFS='/' read -ra ADDR <<< "${folder_path}"
+folder=${ADDR[-1]}
+
+mkdir -p $output_folder
+
+counter=0
+startindex=0
+while [ $startindex -lt $nb_elements ]
+do
+
+  outfile="${folder}_${step}_${counter}.png"
+  echo $outfile
+
+  ./${build_folder}/main/rawls_merge_mean --folder ${folder_path} --random 0 --samples ${step} --startindex $startindex --outfile $output_folder/$outfile
+
+  counter=$(( $counter + 1 ))  
+  startindex=$(($startindex + $step))
+done
+  
+      

+ 52 - 0
run/reconstruct_png_step_random.sh

@@ -0,0 +1,52 @@
+#! /bin/bash
+
+if [ -z "$1" ]
+  then
+    echo "No argument supplied"
+    echo "Need data folder"
+    exit 1
+fi
+
+if [ -z "$2" ]
+  then
+    echo "No argument supplied"
+    echo "Need output folder"
+    exit 1
+fi
+
+if [ -z "$3" ]
+  then
+    echo "No argument supplied"
+    echo "Need step output images expected (step of samples)"
+    exit 1
+fi
+
+prefix="p3d_"
+build_folder="build"
+
+folder_path=$1
+output_folder=$2
+step=$3
+
+nb_elements=$(ls -l ${folder_path} | grep ${prefix} | wc -l)
+
+IFS='/' read -ra ADDR <<< "${folder_path}"
+folder=${ADDR[-1]}
+
+mkdir -p $output_folder
+
+counter=0
+startindex=0
+while [ $startindex -lt $nb_elements ]
+do
+  startindex=$(($startindex + $step))
+
+  outfile="${folder}_${step}_${counter}.png"
+  echo $outfile
+
+  ./${build_folder}/main/rawls_merge_mean --folder ${folder_path} --random 1 --samples ${step} --outfile $output_folder/$outfile
+
+  counter=$(( $counter + 1 ))
+done
+  
+      

+ 33 - 0
utils/compare_images.py

@@ -0,0 +1,33 @@
+# main imports
+import os, sys, argparse
+
+# image processing imports
+from PIL import Image
+import ipfml.iqa.fr as fr
+
+def main():
+
+    parser = argparse.ArgumentParser(description="Compare 2 images and return difference using metric")
+
+    parser.add_argument('--img1', type=str, help='First image')
+    parser.add_argument('--img2', type=str, help='Second image')
+    parser.add_argument('--metric', type=str, help='metric to use to compare', choices=['ssim', 'mse', 'rmse', 'mae', 'psnr'])
+    args = parser.parse_args()
+
+    param_img1 = args.img1
+    param_img2 = args.img2
+    param_metric  = args.metric
+
+    image1 = Image.open(param_img1)
+    image2 = Image.open(param_img2)
+
+    try:
+        fr_iqa = getattr(fr, param_metric)
+    except AttributeError:
+        raise NotImplementedError("FR IQA `{}` not implement `{}`".format(fr.__name__, param_metric))
+
+    print(fr_iqa(image1, image2))
+
+
+if __name__== "__main__":
+    main()