1 #!/bin/bash 2 3 filename=$1 4 cleanFilename=$2 5 6 regexN='^N[0-9]' 7 regexData='(D/RefocusFilter)' 8 regexNum='^[1-7]\.' 9 10 sum=0 11 InitializeSum=0 12 UnpackInputImageSum=0 13 MarkLayerMaskSum=0 14 ComputeLayerMatteBehindFocalDepthSum=0 15 ComputeIntegralImageForLayerBehindFocalDepthSum=0 16 FilterLayerBehindFocalDepthSum=0 17 updateSharpImageUsingFuzzyImageSum=0 18 ComputeLayerMatteInFrontOfFocalDepthSum=0 19 ComputeIntegralImageForLayerInFrontOfFocalDepthSum=0 20 FilterLayerInFrontOfFocalDepthSum=0 21 finalizeFuzzyImageUsingSharpImageSum=0 22 PackOutputImageSum=0 23 24 while read line;do 25 if [[ $line =~ $regexN ]]; 26 then 27 echo "Initialize: $InitializeSum" >> $cleanFilename 28 InitializeSum=0 29 echo "UnpackInputImage: $UnpackInputImageSum" >> $cleanFilename 30 UnpackInputImageSum=0 31 echo "MarkLayerMask: $MarkLayerMaskSum" >> $cleanFilename 32 MarkLayerMaskSum=0 33 echo "ComputeLayerMatteBehindFocalDepth: $ComputeLayerMatteBehindFocalDepthSum" >> $cleanFilename 34 ComputeLayerMatteBehindFocalDepthSum=0 35 echo "ComputeIntegralImageForLayerBehindFocalDepth: $ComputeIntegralImageForLayerBehindFocalDepthSum" >> $cleanFilename 36 ComputeIntegralImageForLayerBehindFocalDepthSum=0 37 echo "FilterLayerBehindFocalDepth: $FilterLayerBehindFocalDepthSum" >> $cleanFilename 38 FilterLayerBehindFocalDepthSum=0 39 echo "updateSharpImageUsingFuzzyImage: $updateSharpImageUsingFuzzyImageSum" >> $cleanFilename 40 updateSharpImageUsingFuzzyImageSum=0 41 echo "ComputeLayerMatteInFrontOfFocalDepth: $ComputeLayerMatteInFrontOfFocalDepthSum" >> $cleanFilename 42 ComputeLayerMatteInFrontOfFocalDepthSum=0 43 echo "ComputeIntegralImageForLayerInFrontOfFocalDepth: $ComputeIntegralImageForLayerInFrontOfFocalDepthSum" >> $cleanFilename 44 ComputeIntegralImageForLayerInFrontOfFocalDepthSum=0 45 echo "FilterLayerInFrontOfFocalDepth: $FilterLayerInFrontOfFocalDepthSum" >> $cleanFilename 46 FilterLayerInFrontOfFocalDepthSum=0 47 echo "finalizeFuzzyImageUsingSharpImage: $finalizeFuzzyImageUsingSharpImageSum" >> $cleanFilename 48 finalizeFuzzyImageUsingSharpImageSum=0 49 echo "PackOutputImage: $PackOutputImageSum" >> $cleanFilename 50 PackOutputImageSum=0 51 echo $line >> $cleanFilename 52 53 elif [[ $line =~ $regexData ]]; 54 then 55 #collect corresponding data 56 newLine=`echo $line|grep -oE '[0-9]+ ns'|awk '{print $1}'` 57 sum=`echo $((sum+newLine))` 58 if [[ $line =~ 'Initialize' ]]; 59 then 60 InitializeSum=`echo $((InitializeSum+newLine))`; 61 elif [[ $line =~ 'UnpackInputImage' ]]; 62 then 63 UnpackInputImageSum=`echo $((UnpackInputImageSum+newLine))` 64 elif [[ $line =~ 'MarkLayerMask' ]]; 65 then 66 MarkLayerMaskSum=`echo $((MarkLayerMaskSum+newLine))` 67 elif [[ $line =~ 'ComputeLayerMatteBehindFocalDepth' ]]; 68 then 69 ComputeLayerMatteBehindFocalDepthSum=`echo $((ComputeLayerMatteBehindFocalDepthSum+newLine))` 70 elif [[ $line =~ 'ComputeIntegralImageForLayerBehindFocalDepth' ]]; 71 then 72 ComputeIntegralImageForLayerBehindFocalDepthSum=`echo $((ComputeIntegralImageForLayerBehindFocalDepthSum+newLine))` 73 elif [[ $line =~ 'FilterLayerBehindFocalDepth' ]]; 74 then 75 FilterLayerBehindFocalDepthSum=`echo $((FilterLayerBehindFocalDepthSum+newLine))` 76 elif [[ $line =~ [uU]pdateSharpImageUsingFuzzyImage ]]; 77 then 78 updateSharpImageUsingFuzzyImageSum=`echo $((updateSharpImageUsingFuzzyImageSum+newLine))` 79 elif [[ $line =~ 'ComputeLayerMatteInFrontOfFocalDepth' ]]; 80 then 81 ComputeLayerMatteInFrontOfFocalDepthSum=`echo $((ComputeLayerMatteInFrontOfFocalDepthSum+newLine))` 82 elif [[ $line =~ 'ComputeIntegralImageForLayerInFrontOfFocalDepth' ]]; 83 then 84 ComputeIntegralImageForLayerInFrontOfFocalDepthSum=`echo $((ComputeIntegralImageForLayerInFrontOfFocalDepthSum+newLine))` 85 elif [[ $line =~ 'FilterLayerInFrontOfFocalDepth' ]]; 86 then 87 FilterLayerInFrontOfFocalDepthSum=`echo $((FilterLayerInFrontOfFocalDepthSum+newLine))` 88 elif [[ $line =~ [fF]inalizeFuzzyImageUsingSharpImage ]]; 89 then 90 finalizeFuzzyImageUsingSharpImageSum=`echo $((finalizeFuzzyImageUsingSharpImageSum+newLine))` 91 elif [[ $line =~ 'PackOutputImage' ]]; 92 then 93 PackOutputImageSum=`echo $((PackOutputImageSum+newLine))` 94 fi 95 96 elif [[ $line =~ $regexNum ]]; 97 then 98 if ! [[ $line =~ '1.' ]]; 99 then 100 echo "Initialize: $InitializeSum" >> $cleanFilename 101 InitializeSum=0 102 echo "UnpackInputImage: $UnpackInputImageSum" >> $cleanFilename 103 UnpackInputImageSum=0 104 echo "MarkLayerMask: $MarkLayerMaskSum" >> $cleanFilename 105 MarkLayerMaskSum=0 106 echo "ComputeLayerMatteBehindFocalDepth: $ComputeLayerMatteBehindFocalDepthSum" >> $cleanFilename 107 ComputeLayerMatteBehindFocalDepthSum=0 108 echo "ComputeIntegralImageForLayerBehindFocalDepth: $ComputeIntegralImageForLayerBehindFocalDepthSum" >> $cleanFilename 109 ComputeIntegralImageForLayerBehindFocalDepthSum=0 110 echo "FilterLayerBehindFocalDepth: $FilterLayerBehindFocalDepthSum" >> $cleanFilename 111 FilterLayerBehindFocalDepthSum=0 112 echo "updateSharpImageUsingFuzzyImage: $updateSharpImageUsingFuzzyImageSum" >> $cleanFilename 113 updateSharpImageUsingFuzzyImageSum=0 114 echo "ComputeLayerMatteInFrontOfFocalDepth: $ComputeLayerMatteInFrontOfFocalDepthSum" >> $cleanFilename 115 ComputeLayerMatteInFrontOfFocalDepthSum=0 116 echo "ComputeIntegralImageForLayerInFrontOfFocalDepth: $ComputeIntegralImageForLayerInFrontOfFocalDepthSum" >> $cleanFilename 117 ComputeIntegralImageForLayerInFrontOfFocalDepthSum=0 118 echo "FilterLayerInFrontOfFocalDepth: $FilterLayerInFrontOfFocalDepthSum" >> $cleanFilename 119 FilterLayerInFrontOfFocalDepthSum=0 120 echo "finalizeFuzzyImageUsingSharpImage: $finalizeFuzzyImageUsingSharpImageSum" >> $cleanFilename 121 finalizeFuzzyImageUsingSharpImageSum=0 122 echo "PackOutputImage: $PackOutputImageSum" >> $cleanFilename 123 PackOutputImageSum=0 124 fi 125 echo $line >> $cleanFilename 126 fi 127 done < $filename 128 129 echo $filename 130