Created
March 26, 2011 12:29
-
-
Save pceres/888239 to your computer and use it in GitHub Desktop.
Revisions
-
pceres revised this gist
Apr 3, 2011 . 1 changed file with 8 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,9 +19,8 @@ logfile=report.txt # logfile with the list of all photos sorted by logfile_full=report_unsorted.txt # logfile with the list of all photos not sorted temp_folder=/tmp # temporary folder output_folder=blurry_folder # folder into which the most blurred photos are copied perc_output_images=20 # [%] percentage of most blurred images to be copied into output folder # @@ -47,23 +46,26 @@ if [ -d $input ]; then # blur_detector <folder_with_images> # echo "batch blur estimator..." touch $logfile_full rm $logfile_full find $input -name "*.$image_ext" -exec blur_detector {} >> $logfile_full \; # sort by blur index (from worst to best) cat $logfile_full | sort -d -k 8.2 > $logfile # copy blurred images to output folder num_files=`cat $logfile | wc -l` # number of image files found num_output_images=`echo $num_files*$perc_output_images/100.0 | bc | gawk '{printf("%d\n",int($1)+1)}'` # take a percentage echo "copying $num_output_images (out of $num_files) blurriest photos into output folder..." mkdir $output_folder head $logfile -n $num_output_images | gawk '{n=split($1,a,"/");filename=sprintf("%03d_%s", FNR, a[n]);print filename; system("cp " $1 " ./'$output_folder'/" filename)}' else # report on single file # -
pceres revised this gist
Mar 29, 2011 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,16 @@ #! /bin/bash # # Author: Pasquale Ceres ([email protected]) # License: GPL ver. 3 # # Script originally developed for the # "San Lorenzo Martire Caposele Church Records Digitalization Project" # # http://www.facebook.com/group.php?gid=188973755117&v=photos # http://ars.altervista.org/PhpGedView/index.php # # # parameters # @@ -10,6 +21,8 @@ temp_folder=/tmp # temporary folder output_folder=blurry_folder # folder into which the most blurred photos are copied num_output_images=10 # number of most blurred images to be copied into output folder # num_output_images=`ls -Al /home/ceres/Desktop/work/test/*.JPG | wc -l` && echo $num_files*0.2 | bc | gawk '{printf("%d\n",int($1)+1)}' # # show usage if no params in input -
pceres revised this gist
Mar 26, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -48,7 +48,7 @@ if [ -d $input ]; then echo "copying blurryed photos inside output folder..." mkdir $output_folder head $logfile -n $num_output_images | gawk '{n=split($1,a,"/");filename=sprintf("%03d_%s", FNR, a[n]);print filename; system("cp " $1 " ./'$output_folder'/" filename)}' else -
pceres revised this gist
Mar 26, 2011 . 1 changed file with 17 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,19 @@ #! /bin/bash # # parameters # image_ext=JPG # image extension logfile=report.txt # logfile with the list of all photos sorted by blur level logfile_full=report_unsorted.txt # logfile with the list of all photos not sorted temp_folder=/tmp # temporary folder output_folder=blurry_folder # folder into which the most blurred photos are copied num_output_images=10 # number of most blurred images to be copied into output folder # # show usage if no params in input # if [ ! $# == 1 ]; then echo "Usage:" echo "$0 <filename> : analyse the single image, determining its blur factor" @@ -8,17 +22,11 @@ if [ ! $# == 1 ]; then fi # # calculations # input=$1 if [ -d $input ]; then # report on the files in the folder # -
pceres revised this gist
Mar 26, 2011 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,5 @@ #! /bin/bash if [ ! $# == 1 ]; then echo "Usage:" echo "$0 <filename> : analyse the single image, determining its blur factor" -
pceres revised this gist
Mar 26, 2011 . 1 changed file with 20 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ #! /bin/bash # head report_step0_sorted.txt -n 368 | gawk '{n=split($1,a,"/");filename=sprintf("%03d_%s", FNR, a[n]);print filename; system("cp " $1 " ./blurry/" filename)}' if [ ! $# == 1 ]; then echo "Usage:" echo "$0 <filename> : analyse the single image, determining its blur factor" @@ -12,9 +14,12 @@ input=$1 # extension of files to be analysed image_ext=JPG # image extension logfile=report.txt # logfile with the list of all photos sorted by blur level logfile_full=report_unsorted.txt # logfile with the list of all photos not sorted temp_folder=/tmp # temporary folder output_folder=blurry_folder # folder into which the most blurred photos are copied num_output_images=10 # number of most blurred images to be copied into output folder if [ -d $input ]; then # report on the files in the folder @@ -23,14 +28,22 @@ if [ -d $input ]; then # blur_detector <folder_with_images> # echo "batch blur estimator..." touch $logfile_full rm $logfile_full find $input -name "*.$image_ext" -exec blur_detector {} >> $logfile_full \; # sort by blur index (from worst to best) cat $logfile_full | sort -d -k 8.2 > $logfile echo "copying blurryed photos inside output folder..." mkdir $output_folder head $logfile -n $num_output_images | gawk '{n=split($1,a,"/");filename=sprintf("%03d_%s", FNR, a[n]);print filename; system("cp " $1 " ./'$logfile'/" filename)}' else # report on single file -
pceres revised this gist
Mar 26, 2011 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,13 @@ #! /bin/bash if [ ! $# == 1 ]; then echo "Usage:" echo "$0 <filename> : analyse the single image, determining its blur factor" echo "$0 <folder> : analyse the images inside the folder" exit fi input=$1 -
pceres renamed this gist
Mar 26, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
pceres created this gist
Mar 26, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,57 @@ #! /bin/bash input=$1 # extension of files to be analysed image_ext=JPG logfile=report.txt temp_folder=/tmp if [ -d $input ]; then # report on the files in the folder # # usage: # blur_detector <folder_with_images> # echo "batch blur estimator..." touch $logfile rm $logfile find $input -name "*.$image_ext" -exec blur_detector {} >> $logfile \; # sort by blur index (from worst to best) cat $logfile | sort -d -k 8.2 else # report on single file # # usage: # blur_detector <image_filename> # filename=$input # original size size0=`identify $filename | gawk '{print $3}'` # reduce size, just take upper part of image convert $filename -gravity north -crop 100x20% +repage $temp_folder/check0.jpg size=`identify $temp_folder/check0.jpg | gawk '{print $3}'` # create black image convert -size $size xc:black $temp_folder/black.jpg # create check image convert -noise 2 -sigmoidal-contrast 6x25% -edge 2 $temp_folder/check0.jpg $temp_folder/check.jpg # calculate blur factor blur_value=`compare -metric RMSE $temp_folder/check.jpg $temp_folder/black.jpg $temp_folder/out.jpg 2>&1` echo "$filename : $size0 -> $size : $blur_value" # remove work files rm $temp_folder/check0.jpg $temp_folder/check.jpg $temp_folder/black.jpg $temp_folder/out.jpg fi