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