Changeset 33589

Show
Ignore:
Timestamp:
21.10.2019 21:45:10 (3 weeks ago)
Author:
cpb16
Message:

final01. Need Map results still

Location:
other-projects/is-sheet-music-encore/trunk
Files:
34 added
12 modified

Legend:

Unmodified
Added
Removed
  • other-projects/is-sheet-music-encore/trunk/EndToEndSystem.sh

    r33458 r33589  
    1414#Test/Dev Scripts 
    1515#**************************************************************************************************** 
    16  
    17  
    18  
     16if [ $type == "argTest" ] ; then 
     17    if [ $# != 3 ] ; then 
     18        echo "Usage:./EndToEndSystem <ClassifierType> <ResultSubDirectory> <borderIgnoreAmount> " 
     19        exit 1 
     20    fi 
     21    location=$2 
     22    borderIgnoreAmount=$3 
     23    cd image-identification-terminal     
     24    mkdir log-EndToEnd/$location/ 
     25    #Delete files if exists 
     26    if [ -d log-EndToEnd/$location ] ; then 
     27        echo "removing folder logEndToEnd/$location"  
     28        rm -r log-EndToEnd/$location/ 
     29        mkdir log-EndToEnd/$location/ 
     30    fi 
     31 
     32    echo $'\n***********************************************\n' >> log-EndToEnd/$location/results.txt 
     33    echo "Start Time: $(date +"%T")" >> log-EndToEnd/$location/results.txt #Add End Time 
     34    echo >> log-EndToEnd/$location/results.txt #Add Space 
     35    cat configClassifierComparison.properties >> log-EndToEnd/$location/results.txt #Add config 
     36    echo $'ARGUEMENT DETAILS: \n' >> log-EndToEnd/$location/results.txt 
     37    echo "borderIgnoreAmount: $borderIgnoreAmount.   That is to say that outer $borderIgnoreAmount% of the image was not considered by the algorithm." >> log-EndToEnd/$location/results.txt 
     38    echo "[NYI]" >> log-EndToEnd/$location/results.txt 
     39    echo >> log-EndToEnd/$location/results.txt #Space 
     40     
     41    #Compile 
     42    echo "Compiling java programs..." 
     43    javac javaAccuracyCalculator.java 
     44    javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java; 
     45     
     46    #Classifiers 
     47    echo "Successfuly Compiled, running classifer now..." 
     48    ./runClassiferV02.sh -argTest /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU morphology log-EndToEnd/$location/log-morph-MU.txt $borderIgnoreAmount 
     49     
     50    #Accuracy Calculation 
     51    echo "Successfuly Classified, writing results now..." 
     52    java javaAccuracyCalculator log-EndToEnd/$location/log-morph-MU.txt morph-MU log-EndToEnd/$location/results.txt 
     53    echo >>log-EndToEnd/$location/results.txt 
     54    echo "End Time: $(date +"%T")" >> log-EndToEnd/$location/results.txt #Add End Time 
     55    #.././calculateCorpusAccuracy.sh 
     56     
     57    #less log-EndToEnd/$location/results.txt  
     58    exit $? 
     59fi 
    1960 
    2061#**************************************************************************************************** 
     
    3071    fi 
    3172    echo $new_page_num 
    32     exit 1 
     73    exit $? 
    3374fi 
    3475#**************************************************************************************************** 
    3576#Classifier Scripts [HIGHRES BY DEFUALT] 
    3677#**************************************************************************************************** 
     78 
     79#Morphology - No args 
     80 
    3781if [ $type == "morph" ] ; then 
    3882    if [ $# != 2 ] ; then 
    39         echo "Usage:./EndToEndSystem cluster <ResultSubDirectory> " 
     83        echo "Usage:./EndToEndSystem <ClassifierType> <ResultSubDirectory> " 
    4084        exit 1 
    4185    fi 
     
    4993    #Classifiers 
    5094    echo "Successfuly Compiled, running classifer now..." 
    51     ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU morphology log-EndToEnd/$location/log-morph-MU.txt -allNew 
    52     ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/BK morphology log-EndToEnd/$location/log-morph-BK.txt -allNew 
    53     ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MP morphology log-EndToEnd/$location/log-morph-MP.txt -allNew 
    54     ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/SE morphology log-EndToEnd/$location/log-morph-SE.txt -allNew 
     95    ./runClassiferV02.sh -all /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU morphology log-EndToEnd/$location/log-morph-MU.txt  
     96    ./runClassiferV02.sh -all /Scratch/cpb16/is-sheet-music-encore/hires-download-images/BK morphology log-EndToEnd/$location/log-morph-BK.txt  
     97    ./runClassiferV02.sh -all /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MP morphology log-EndToEnd/$location/log-morph-MP.txt  
     98    ./runClassiferV02.sh -all /Scratch/cpb16/is-sheet-music-encore/hires-download-images/SE morphology log-EndToEnd/$location/log-morph-SE.txt  
    5599    #Results 
    56100    echo "Successfuly Classified, writing results now..." 
     
    67111    .././calculateCorpusAccuracy.sh 
    68112    less log-EndToEnd/$location/results.txt  
    69     exit 1 
    70 fi 
     113    exit $? 
     114fi 
     115 
     116#Cluster - No args 
    71117 
    72118if [ $type == "cluster" ] ; then 
    73119     
    74120    if [ $# != 2 ] ; then 
    75         echo "Usage:./EndToEndSystem cluster <ResultSubDirectory>" 
     121        echo "Usage:./EndToEndSystem <ClassifierType> <ResultSubDirectory>" 
    76122        exit 1 
    77123    fi 
     
    84130    #Classifiers 
    85131    echo "Successfuly Compiled, running classifer now..." 
    86     #./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU cluster log-EndToEnd/$location/log-cluster-MU.txt -allNew 
    87     #./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/BK cluster log-EndToEnd/$location/log-cluster-BK.txt -allNew 
    88     #./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MP cluster log-EndToEnd/$location/log-cluster-MP.txt -allNew 
    89     #./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/SE cluster log-EndToEnd/$location/log-cluster-SE.txt -allNew 
     132    #./runClassiferV02.sh -all /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU cluster log-EndToEnd/$location/log-cluster-MU.txt 
     133    #./runClassiferV02.sh -all /Scratch/cpb16/is-sheet-music-encore/hires-download-images/BK cluster log-EndToEnd/$location/log-cluster-BK.txt 
     134    #./runClassiferV02.sh -all /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MP cluster log-EndToEnd/$location/log-cluster-MP.txt 
     135    #./runClassiferV02.sh -all /Scratch/cpb16/is-sheet-music-encore/hires-download-images/SE cluster log-EndToEnd/$location/log-cluster-SE.txt 
    90136    #Results 
    91137    echo "Successfuly Classified, writing results now..." 
     
    102148    .././calculateCorpusAccuracy.sh 
    103149    less log-EndToEnd/$location/results.txt  
    104     exit 1 
    105 fi 
     150    exit $? 
     151fi 
     152 
     153#Morphology - Border Args -Corpus - No Map 
     154 
     155if [ $type == "morph-border" ] ; then 
     156    if [ $# != 3 ] ; then 
     157        echo "Usage:./EndToEndSystem <ClassifierType> <ResultSubDirectory> <borderIgnoreAmount> " 
     158        exit 1 
     159    fi 
     160    location=$2 
     161    borderIgnoreAmount=$3 
     162    cd image-identification-terminal     
     163    mkdir log-EndToEnd/$location/ 
     164    #Delete files if exists 
     165    if [ -d log-EndToEnd/$location ] ; then 
     166        echo "removing folder logEndToEnd/$location"  
     167        rm -r log-EndToEnd/$location/ 
     168        mkdir log-EndToEnd/$location/ 
     169    fi 
     170 
     171    echo $'\n***********************************************\n' >> log-EndToEnd/$location/results.txt 
     172    echo "Start Time: $(date +"%T")" >> log-EndToEnd/$location/results.txt #Add End Time 
     173    echo >> log-EndToEnd/$location/results.txt #Add Space 
     174    cat configClassifierComparison.properties >> log-EndToEnd/$location/results.txt #Add config 
     175    echo $'ARGUEMENT DETAILS: \n' >> log-EndToEnd/$location/results.txt 
     176    echo "borderIgnoreAmount: $borderIgnoreAmount.   That is to say that outer $borderIgnoreAmount% of the image was not considered by the algorithm." >> log-EndToEnd/$location/results.txt 
     177    echo "[NYI]" >> log-EndToEnd/$location/results.txt 
     178    echo >> log-EndToEnd/$location/results.txt #Space 
     179     
     180    #Compile 
     181    echo "Compiling java programs..." 
     182    javac javaAccuracyCalculator.java 
     183    javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java; 
     184     
     185    #Classifiers 
     186    echo "Successfuly Compiled, running classifer now..." 
     187    ./runClassiferV02.sh -borderAll /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU morphology log-EndToEnd/$location/log-morph-MU.txt $borderIgnoreAmount 
     188    ./runClassiferV02.sh -borderAll /Scratch/cpb16/is-sheet-music-encore/hires-download-images/BK morphology log-EndToEnd/$location/log-morph-BK.txt $borderIgnoreAmount 
     189    ./runClassiferV02.sh -borderAll /Scratch/cpb16/is-sheet-music-encore/hires-download-images/SE morphology log-EndToEnd/$location/log-morph-SE.txt $borderIgnoreAmount 
     190     
     191    #Accuracy Calculation 
     192    echo "Successfuly Classified, writing results now..." 
     193    java javaAccuracyCalculator log-EndToEnd/$location/log-morph-MU.txt morph-MU log-EndToEnd/$location/results.txt 
     194    java javaAccuracyCalculator log-EndToEnd/$location/log-morph-BK.txt morph-BK log-EndToEnd/$location/results.txt 
     195    java javaAccuracyCalculator log-EndToEnd/$location/log-morph-SE.txt morph-SE log-EndToEnd/$location/results.txt 
     196    echo >>log-EndToEnd/$location/results.txt 
     197    echo "End Time: $(date +"%T")" >> log-EndToEnd/$location/results.txt #Add End Time 
     198    #.././calculateCorpusAccuracy.sh 
     199     
     200    #less log-EndToEnd/$location/results.txt  
     201    exit $? 
     202fi 
     203 
     204#HoughTransform - Cluster Args -Corpus - No Map 
     205 
     206if [ $type == "cluster-border" ] ; then 
     207    if [ $# != 3 ] ; then 
     208        echo "Usage:./EndToEndSystem <ClassifierType> <ResultSubDirectory> <borderIgnoreAmount> " 
     209        exit 1 
     210    fi 
     211    location=$2 
     212    borderIgnoreAmount=$3 
     213    cd image-identification-terminal     
     214    mkdir log-EndToEnd/$location/ 
     215    #Delete files if exists 
     216    if [ -d log-EndToEnd/$location ] ; then 
     217        echo "removing folder logEndToEnd/$location"  
     218        rm -r log-EndToEnd/$location/ 
     219        mkdir log-EndToEnd/$location/ 
     220    fi 
     221 
     222    echo $'\n***********************************************\n' >> log-EndToEnd/$location/results.txt 
     223    echo "Start Time: $(date +"%T")" >> log-EndToEnd/$location/results.txt #Add End Time 
     224    echo >> log-EndToEnd/$location/results.txt #Add Space 
     225    cat configClassifierComparison.properties >> log-EndToEnd/$location/results.txt #Add config 
     226    echo $'ARGUEMENT DETAILS: \n' >> log-EndToEnd/$location/results.txt 
     227    echo "borderIgnoreAmount: $borderIgnoreAmount.   That is to say that outer $borderIgnoreAmount% of the image was not considered by the algorithm." >> log-EndToEnd/$location/results.txt 
     228    echo "[NYI]" >> log-EndToEnd/$location/results.txt 
     229    echo >> log-EndToEnd/$location/results.txt #Space 
     230     
     231    #Compile 
     232    echo "Compiling java programs..." 
     233    javac javaAccuracyCalculator.java 
     234    javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java; 
     235     
     236    #Classifiers 
     237    echo "Successfuly Compiled, running classifer now..." 
     238    ./runClassiferV02.sh -borderAll /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU cluster log-EndToEnd/$location/log-cluster-MU.txt $borderIgnoreAmount 
     239    ./runClassiferV02.sh -borderAll /Scratch/cpb16/is-sheet-music-encore/hires-download-images/BK cluster log-EndToEnd/$location/log-cluster-BK.txt $borderIgnoreAmount 
     240    ./runClassiferV02.sh -borderAll /Scratch/cpb16/is-sheet-music-encore/hires-download-images/SE cluster log-EndToEnd/$location/log-cluster-SE.txt $borderIgnoreAmount 
     241     
     242    #Accuracy Calculation 
     243    echo "Successfuly Classified, writing results now..." 
     244    java javaAccuracyCalculator log-EndToEnd/$location/log-cluster-MU.txt cluster-MU log-EndToEnd/$location/results.txt 
     245    java javaAccuracyCalculator log-EndToEnd/$location/log-cluster-BK.txt cluster-BK log-EndToEnd/$location/results.txt 
     246    java javaAccuracyCalculator log-EndToEnd/$location/log-cluster-SE.txt cluster-SE log-EndToEnd/$location/results.txt 
     247    echo >>log-EndToEnd/$location/results.txt 
     248    echo "End Time: $(date +"%T")" >> log-EndToEnd/$location/results.txt #Add End Time 
     249    #.././calculateCorpusAccuracy.sh 
     250     
     251    #less log-EndToEnd/$location/results.txt  
     252    exit $? 
     253fi 
     254 
     255 
     256 
     257#HoughTransform - Count Args -Corpus - No Map                                                                                                                                                                  
     258 
     259if [ $type == "count-border" ] ; then 
     260        if [ $# != 3 ] ; then 
     261                echo "Usage:./EndToEndSystem <ClassifierType> <ResultSubDirectory> <borderIgnoreAmount> " 
     262                exit 1 
     263        fi 
     264        location=$2 
     265        borderIgnoreAmount=$3 
     266        cd image-identification-terminal 
     267        mkdir log-EndToEnd/$location/ 
     268        #Delete files if exists                                                                                                                                                                                  
     269        if [ -d log-EndToEnd/$location ] ; then 
     270                echo "removing folder logEndToEnd/$location" 
     271                rm -r log-EndToEnd/$location/ 
     272                mkdir log-EndToEnd/$location/ 
     273        fi 
     274 
     275        echo $'\n***********************************************\n' >> log-EndToEnd/$location/results.txt 
     276        echo "Start Time: $(date +"%T")" >> log-EndToEnd/$location/results.txt #Add End Time                                                                                                                     
     277        echo >> log-EndToEnd/$location/results.txt #Add Space                                                                                                                                                    
     278        cat configClassifierComparison.properties >> log-EndToEnd/$location/results.txt #Add config                                                                                                              
     279        echo $'ARGUEMENT DETAILS: \n' >> log-EndToEnd/$location/results.txt 
     280        echo "borderIgnoreAmount: $borderIgnoreAmount.   That is to say that outer $borderIgnoreAmount% of the image was not considered by the algorithm." >> log-EndToEnd/$location/results.txt 
     281        echo "[NYI]" >> log-EndToEnd/$location/results.txt 
     282        echo >> log-EndToEnd/$location/results.txt #Space                                                                                                                                                        
     283 
     284        #Compile                                                                                                                                                                                                 
     285        echo "Compiling java programs..." 
     286        javac javaAccuracyCalculator.java 
     287        javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java; 
     288 
     289        #Classifiers                                                                                                                                                                                             
     290        echo "Successfuly Compiled, running classifer now..." 
     291        ./runClassiferV02.sh -borderAll /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU count log-EndToEnd/$location/log-count-MU.txt $borderIgnoreAmount 
     292        ./runClassiferV02.sh -borderAll /Scratch/cpb16/is-sheet-music-encore/hires-download-images/BK count log-EndToEnd/$location/log-count-BK.txt $borderIgnoreAmount 
     293        ./runClassiferV02.sh -borderAll /Scratch/cpb16/is-sheet-music-encore/hires-download-images/SE count log-EndToEnd/$location/log-count-SE.txt $borderIgnoreAmount 
     294 
     295        #Accuracy Calculation                                                                                                                                                                                    
     296        echo "Successfuly Classified, writing results now..." 
     297        java javaAccuracyCalculator log-EndToEnd/$location/log-count-MU.txt count-MU log-EndToEnd/$location/results.txt 
     298        java javaAccuracyCalculator log-EndToEnd/$location/log-count-BK.txt count-BK log-EndToEnd/$location/results.txt 
     299        java javaAccuracyCalculator log-EndToEnd/$location/log-count-SE.txt count-SE log-EndToEnd/$location/results.txt 
     300        echo >>log-EndToEnd/$location/results.txt 
     301        echo "End Time: $(date +"%T")" >> log-EndToEnd/$location/results.txt #Add End Time                                                                                                                       
     302        #.././calculateCorpusAccuracy.sh                                                                                                                                                                         
     303 
     304        #less log-EndToEnd/$location/results.txt                                                                                                                                                                 
     305        exit $? 
     306fi 
     307 
     308 
     309 
     310 
     311 
     312#Map SCRIPT                                                                                                                                                                  
     313 
     314if [ $type == "map-hough-morph" ] ; then 
     315        if [ $# != 3 ] ; then 
     316                echo "Usage:./EndToEndSystem <ClassifierType> <ResultSubDirectory> <borderIgnoreAmount> " 
     317                exit 1 
     318        fi 
     319        location=$2 
     320        borderIgnoreAmount=$3 
     321        cd image-identification-terminal 
     322        mkdir log-EndToEnd/$location/ 
     323        #Delete files if exists                                                                                                                                                                                  
     324        if [ -d log-EndToEnd/$location ] ; then 
     325                echo "removing folder logEndToEnd/$location" 
     326                rm -r log-EndToEnd/$location/ 
     327                mkdir log-EndToEnd/$location/ 
     328        fi 
     329 
     330        echo $'\n***********************************************\n' >> log-EndToEnd/$location/results.txt 
     331        echo "Start Time: $(date +"%T")" >> log-EndToEnd/$location/results.txt #Add End Time                                                                                                                     
     332        echo >> log-EndToEnd/$location/results.txt #Add Space                                                                                                                                                    
     333        cat configClassifierComparison.properties >> log-EndToEnd/$location/results.txt #Add  config                                                                                                              
     334        echo $'ARGUEMENT DETAILS: \n' >> log-EndToEnd/$location/results.txt 
     335        echo "borderIgnoreAmount: $borderIgnoreAmount.   That is to say that outer $borderIgnoreAmount% of the image was not considered by the algorithm." >> log-EndToEnd/$location/results.txt 
     336        echo "[NYI]" >> log-EndToEnd/$location/results.txt 
     337        echo >> log-EndToEnd/$location/results.txt                                                                                                                                                         
     338 
     339        #Compile                                                                                                                                                                                                 
     340        echo "Compiling java programs..." 
     341        javac javaAccuracyCalculator.java 
     342        javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java; 
     343 
     344        #Classifiers                                                                                                                                                                                             
     345        echo "Successfuly Compiled, running classifer now..." 
     346        ./runClassiferV02.sh -borderAll /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MP count log-EndToEnd/$location/log-count-MP.txt $borderIgnoreAmount 
     347        ./runClassiferV02.sh -borderAll /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MP morphology log-EndToEnd/$location/log-morph-MP.txt $borderIgnoreAmount 
     348 
     349        #Accuracy Calculation                                                                                                                                                                                    
     350        echo "Successfuly Classified, writing results now..." 
     351        java javaAccuracyCalculator log-EndToEnd/$location/log-count-MP.txt count-MP log-EndToEnd/$location/results.txt 
     352        java javaAccuracyCalculator log-EndToEnd/$location/log-morph-MP.txt morph-MP log-EndToEnd/$location/results.txt 
     353         
     354        echo >>log-EndToEnd/$location/results.txt 
     355        echo "End Time: $(date +"%T")" >> log-EndToEnd/$location/results.txt #Add End Time                                                                                                                       
     356        #.././calculateCorpusAccuracy.sh                                                                                                                                                                         
     357 
     358        #less log-EndToEnd/$location/results.txt                                                                                                                                                                 
     359        exit $? 
     360fi 
     361 
     362 
     363 
     364 
    106365 
    107366 
  • other-projects/is-sheet-music-encore/trunk/Makefile

    r33458 r33589  
     1#********** 
     2#Quick CMD for EndToEndSystem.sh 
     3#********** 
     4ete-twentyMU-borders-quick: 
     5    ./EndToEndSystem.sh argTest argTest0p 0 
     6    ./EndToEndSystem.sh argTest argTest5p 5 
     7    ./EndToEndSystem.sh argTest argTest10p 10 
     8    ./EndToEndSystem.sh argTest argTest20p 20 
     9    ./EndToEndSystem.sh argTest argTest40p 40 
     10    cd image-identification-terminal/log-EndToEnd; cat */results.txt > BatchResults.txt 
     11 
     12ete-all-borders-morph: 
     13    ./EndToEndSystem.sh morph-border morph-border-at-0 0 
     14    ./EndToEndSystem.sh morph-border morph-border-at-5 5 
     15    ./EndToEndSystem.sh morph-border morph-border-at-10 10 
     16    ./EndToEndSystem.sh morph-border morph-border-at-20 20 
     17    ./EndToEndSystem.sh morph-border morph-border-at-40 40 
     18    cd image-identification-terminal/log-EndToEnd; cat morph*/results.txt > BatchResultsMorph.txt 
     19 
     20ete-all-borders-cluster: 
     21    ./EndToEndSystem.sh cluster-border cluster-border-at-0 0 
     22    ./EndToEndSystem.sh cluster-border cluster-border-at-5 5 
     23    ./EndToEndSystem.sh cluster-border cluster-border-at-10 10 
     24    ./EndToEndSystem.sh cluster-border cluster-border-at-20 20 
     25    ./EndToEndSystem.sh cluster-border cluster-border-at-40 40 
     26    cd image-identification-terminal/log-EndToEnd; cat cluster*/results.txt > BatchResultsCluster.txt 
     27 
     28ete-all-borders-count: 
     29    ./EndToEndSystem.sh count-border count-border-at-0 0 
     30    ./EndToEndSystem.sh count-border count-border-at-5 5 
     31    ./EndToEndSystem.sh count-border count-border-at-10 10 
     32    ./EndToEndSystem.sh count-border count-border-at-20 20 
     33    ./EndToEndSystem.sh count-border count-border-at-40 40 
     34    cd image-identification-terminal/log-EndToEnd; cat count*/results.txt > BatchResultsCount.txt 
     35 
     36#BLOCKSIZE (CHANGED MAIN COMPARISION JAVA FILE FROM 15 to BLOCKSIZE) 
     37 
     38ete-all-borders-count-BLOCKSIZED: 
     39    ./EndToEndSystem.sh count-border count-borderBLOCKSIZED-at-0 0 
     40    ./EndToEndSystem.sh count-border count-borderBLOCKSIZED-at-5 5 
     41    ./EndToEndSystem.sh count-border count-borderBLOCKSIZED-at-10 10 
     42    ./EndToEndSystem.sh count-border count-borderBLOCKSIZED-at-20 20 
     43    ./EndToEndSystem.sh count-border count-borderBLOCKSIZED-at-40 40 
     44    cd image-identification-terminal/log-EndToEnd; cat count-borderBLOCKSIZED*/results.txt > BatchResultsCountBLOCKSIZED.txt 
     45ete-all-borders-morph-BLOCKSIZED: 
     46    ./EndToEndSystem.sh morph-border morph-borderBLOCKSIZED-at-0 0 
     47    ./EndToEndSystem.sh morph-border morph-borderBLOCKSIZED-at-5 5 
     48    ./EndToEndSystem.sh morph-border morph-borderBLOCKSIZED-at-10 10 
     49    ./EndToEndSystem.sh morph-border morph-borderBLOCKSIZED-at-20 20 
     50    ./EndToEndSystem.sh morph-border morph-borderBLOCKSIZED-at-40 40 
     51    cd image-identification-terminal/log-EndToEnd; cat morph-borderBLOCKSIZED*/results.txt > BatchResultsMorphBLOCKSIZED.txt 
     52     
     53ete-blocksize-both-ob-args: 
     54    ./EndToEndSystem.sh count-border count-borderBLOCKSIZED-at-0 0 
     55    ./EndToEndSystem.sh morph-border morph-borderBLOCKSIZED-at-0 0 
     56     
     57    ./EndToEndSystem.sh count-border count-borderBLOCKSIZED-at-5 5 
     58    ./EndToEndSystem.sh morph-border morph-borderBLOCKSIZED-at-5 5 
     59     
     60    ./EndToEndSystem.sh count-border count-borderBLOCKSIZED-at-10 10 
     61    ./EndToEndSystem.sh morph-border morph-borderBLOCKSIZED-at-10 10 
     62     
     63    ./EndToEndSystem.sh count-border count-borderBLOCKSIZED-at-20 20     
     64    ./EndToEndSystem.sh morph-border morph-borderBLOCKSIZED-at-20 20 
     65     
     66    ./EndToEndSystem.sh count-border count-borderBLOCKSIZED-at-40 40             
     67    ./EndToEndSystem.sh morph-border morph-borderBLOCKSIZED-at-40 40 
     68             
     69    cd image-identification-terminal/log-EndToEnd; cat count-borderBLOCKSIZED*/results.txt > BatchResultsCountBLOCKSIZED.txt     
     70    cd image-identification-terminal/log-EndToEnd; cat morph-borderBLOCKSIZED*/results.txt > BatchResultsMorphBLOCKSIZED.txt     
    171#********** 
    272#Utilities/Test 
     
    1080download-single: 
    1181    ./COMPX520-RUN-PNG-hi-res.sh coo1.ark:/13960/t2t448j81 1 /.. 
    12      
     82 
    1383test-get-page-numbers-map: 
    1484    cd java-gen-corpus; javac javaGenMapPageCountChecker.java 
     
    1787 
    1888test-gen-new-5000-map: 
    19     #MAKE SURE TO RUN source SETUP.bash prior to this cmd 
     89        #MAKE SURE TO RUN source SETUP.bash prior to this cmd 
    2090    cd java-gen-corpus; javac javaGenMap5000ValidIDList.java 
    2191    cd java-gen-corpus; java javaGenMap5000ValidIDList gen-500-MP-hathiFullIDList.txt gen-5000-MapList02.txt 
    22      
     92 
    2393test-gen-new-5000-local-map: 
    24     #MAKE SURE TO RUN source SETUP.bash prior to this cmd 
     94        #MAKE SURE TO RUN source SETUP.bash prior to this cmd 
    2595    cd java-gen-corpus; javac javaGenMapLocal5000ValidIDList.java 
    2696    cd java-gen-corpus; java javaGenMapLocal5000ValidIDList MapListNumPages.txt gen-5000-Local-MapList.txt 
    27      
    28      
    29 run-morphology-20-test: 
    30     cd image-identification-terminal/log-all-hires-new/test; rm *.txt 
    31     cd image-identification-terminal; javac javaAccuracyCalculator.java 
    32     cd image-identification-terminal; javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java; 
    33     cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU morphology log-all-hires-new/test/log-morphology-MU-test.txt -testNew 
     97 
     98run-morphology-20-test-time: 
     99    time make run-morphology-20-test     
     100run-morphology-20-test:      
     101        #cd image-identification-terminal/log-all-hires-new/test; rm *.txt 
     102    cd image-identification-terminal; javac javaAccuracyCalculator.java 
     103    cd image-identification-terminal; javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java; 
     104    cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/SE morphology log-all-hires-new/test/log-morphology-SE-test.txt -testNew  
    34105    cd image-identification-terminal; date >> log-all-hires-new/test/results.txt 
    35106    cd image-identification-terminal; cat configClassifierComparison.properties >> log-all-hires-new/test/results.txt 
    36     cd image-identification-terminal; java javaAccuracyCalculator log-all-hires-new/test/log-morphology-MU-test.txt morphology-MU log-all-hires-new/test/results.txt 
     107    cd image-identification-terminal; java javaAccuracyCalculator log-all-hires-new/test/log-morphology-SE-test.txt morphology-SE log-all-hires-new/test/results.txt 
    37108    cd image-identification-terminal; less log-all-hires-new/test/results.txt  
    38     cd image-identification-terminal; less log-all-hires-new/test/log-morphology-MU-test.txt 
     109    cd image-identification-terminal; less log-all-hires-new/test/log-morphology-SE-test.txt 
    39110 
    40111run-morph-single: 
     
    56127    make hi-res-download-map 
    57128hi-res-download-map: 
    58     ./FirstAndLastTest-DOWNLOADER-PNG.sh java-gen-corpus/gen-5000-Local-MapList.txt MP 
     129    ./COMPX520-MAP-DOWNLOADER-PNG.sh MapListGen/gen-500-Local-MapList-final.txt MP 
    59130 
    60131###################################### 
     
    66137    cd java-gen-corpus; java javaGenFullIDList hathiFull.txt gen-10000-MU-hathiFullIDList.txt MU 
    67138    cd java-gen-corpus; java javaGenFirstAndLastTenIDList gen-10000-MU-hathiFullIDList.txt 10000 gen-10000-MU-hathiValidIDList.txt 
    68     #./FirstAndLastTest-DOWNLOADER-PNG.sh java-gen-corpus/gen-10000-MU-hathiValidIDList.txt MU 
     139#./FirstAndLastTest-DOWNLOADER-PNG.sh java-gen-corpus/gen-10000-MU-hathiValidIDList.txt MU 
    69140 
    70141 
     
    79150 
    80151run-cluster-corpus-hires: 
    81     #Compile 
    82     cd image-identification-terminal; javac javaAccuracyCalculator.java 
    83     cd image-identification-terminal; javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java; 
    84     #Run classifier 
     152#Compile 
     153    cd image-identification-terminal; javac javaAccuracyCalculator.java 
     154    cd image-identification-terminal; javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java; 
     155#Run classifier 
    85156    cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU cluster log-all-hires-new/log-cluster-MU.txt -allNew 
    86157    cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/BK cluster log-all-hires-new/log-cluster-BK.txt -allNew 
    87158    cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MP cluster log-all-hires-new/log-cluster-MP.txt -allNew 
    88159    cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/SE cluster log-all-hires-new/log-cluster-SE.txt -allNew 
    89     #Calculate accuracy 
     160#Calculate accuracy 
    90161    cd image-identification-terminal; echo configClassifierComparison.properties >> log-all-hires-new/results.txt  
    91162    cd image-identification-terminal; java javaAccuracyCalculator log-all-hires-new/log-cluster-MU.txt cluster-MU log-all-hires-new/results.txt 
     
    97168 
    98169run-count-corpus-hires: 
    99     #Compile 
    100     cd image-identification-terminal; javac javaAccuracyCalculator.java 
    101     cd image-identification-terminal; javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java; 
    102     #Run classifier 
     170#Compile 
     171    cd image-identification-terminal; javac javaAccuracyCalculator.java 
     172    cd image-identification-terminal; javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java; 
     173#Run classifier 
    103174    cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU count log-all-hires-new/log-count-MU.txt -allNew 
    104175    cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/BK count log-all-hires-new/log-count-BK.txt -allNew 
    105176    cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MP count log-all-hires-new/log-count-MP.txt -allNew 
    106177    cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/SE count log-all-hires-new/log-count-SE.txt -allNew 
    107     #Calculate accuracy 
     178#Calculate accuracy 
    108179    cd image-identification-terminal; java javaAccuracyCalculator log-all-hires-new/log-count-MU.txt count-MU log-all-hires-new/results.txt 
    109180    cd image-identification-terminal; java javaAccuracyCalculator log-all-hires-new/log-count-BK.txt count-BK log-all-hires-new/results.txt 
     
    115186#Cluster and Count 
    116187run-combo-corpus-hires: 
    117     #Compile 
    118     cd image-identification-terminal; javac javaAccuracyCalculator.java 
    119     cd image-identification-terminal; javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java; 
    120     #Run classifier 
     188#Compile 
     189    cd image-identification-terminal; javac javaAccuracyCalculator.java 
     190    cd image-identification-terminal; javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java; 
     191#Run classifier 
    121192    cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU combo log-all-hires-new/log-combo-MU.txt -allNew 
    122193    cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/BK combo log-all-hires-new/log-combo-BK.txt -allNew 
    123     #cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MP combo log-all-hires-new/log-combo-MP.txt -allNew 
     194#cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MP combo log-all-hires-new/log-combo-MP.txt -allNew 
    124195    cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/SE combo log-all-hires-new/log-combo-SE.txt -allNew 
    125     #Calculate accuracy 
     196#Calculate accuracy 
    126197    cd image-identification-terminal; java javaAccuracyCalculator log-all-hires-new/log-combo-MU.txt combo-MU log-all-hires-new/results.txt 
    127198    cd image-identification-terminal; java javaAccuracyCalculator log-all-hires-new/log-combo-BK.txt combo-BK log-all-hires-new/results.txt 
    128     #cd image-identification-terminal; java javaAccuracyCalculator log-all-hires-new/log-combo-MP.txt combo-MP log-all-hires-new/results.txt 
     199#cd image-identification-terminal; java javaAccuracyCalculator log-all-hires-new/log-combo-MP.txt combo-MP log-all-hires-new/results.txt 
    129200    cd image-identification-terminal; java javaAccuracyCalculator log-all-hires-new/log-combo-SE.txt combo-SE log-all-hires-new/results.txt 
    130201    #Display the results 
     
    150221#************** 
    151222run-houghlinesP-refined-corpus: 
    152     #cd image-identification-terminal; cd log-all; rm *.txt 
     223#cd image-identification-terminal; cd log-all; rm *.txt 
    153224        #Compile 
    154225    cd image-identification-terminal; javac javaAccuracyCalculator.java 
     
    184255        #Display the results 
    185256    cd image-identification-terminal; less log-all-hires/results.txt     
    186      
     257 
    187258#*********** 
    188259#OLDGEN 
    189260#***********     
    190     #MUSIC, Including Sheet music 
     261#MUSIC, Including Sheet music 
    191262gen-500-MU: 
    192263    cd java-gen-corpus; javac *.java 
  • other-projects/is-sheet-music-encore/trunk/image-identification-dev-02/.idea/workspace.xml

    r33458 r33589  
    1515        <entry file="file://$PROJECT_DIR$/image-identification-development/src/Main.java"> 
    1616          <provider selected="true" editor-type-id="text-editor"> 
    17             <state relative-caret-position="557"> 
    18               <caret line="779" column="12" selection-start-line="779" selection-start-column="12" selection-end-line="779" selection-end-column="12" /> 
     17            <state relative-caret-position="2014"> 
     18              <caret line="760" selection-start-line="760" selection-end-line="760" /> 
    1919              <folding> 
    2020                <element signature="imports" expanded="true" /> 
     
    4040        <entry file="file://$PROJECT_DIR$/image-identification-development/src/MainMorph.java"> 
    4141          <provider selected="true" editor-type-id="text-editor"> 
    42             <state relative-caret-position="383"> 
    43               <caret line="236" column="54" selection-start-line="236" selection-start-column="54" selection-end-line="236" selection-end-column="54" /> 
     42            <state relative-caret-position="106"> 
     43              <caret line="1351" column="52" selection-start-line="1351" selection-start-column="52" selection-end-line="1351" selection-end-column="52" /> 
    4444              <folding> 
    4545                <element signature="imports" expanded="true" /> 
    4646                <element signature="method#imageViewer#0;class#MainMorph#0" /> 
    47                 <element signature="e#14232#16729#1" /> 
    48                 <element signature="e#16814#18826#1" /> 
    49                 <element signature="e#18895#21536#1" /> 
    50                 <element signature="e#21620#27308#1" /> 
    51                 <element signature="e#27393#31396#1" /> 
    52                 <element signature="e#31464#32641#1" /> 
    53                 <element signature="e#32710#36690#1" /> 
    54                 <element signature="e#36800#48520#1" /> 
    55                 <element signature="e#45567#45616#0" /> 
    56                 <element signature="e#48614#59515#1" /> 
    57                 <element signature="e#59847#68195#1" /> 
    58                 <element signature="e#61117#61159#0" /> 
    5947              </folding> 
    6048            </state> 
     
    6553        <entry file="file://$PROJECT_DIR$/../image-identification-terminal/javaClassifierComparison.java"> 
    6654          <provider selected="true" editor-type-id="text-editor"> 
    67             <state relative-caret-position="225"> 
    68               <caret line="592" column="12" selection-start-line="592" selection-start-column="12" selection-end-line="592" selection-end-column="12" /> 
     55            <state relative-caret-position="6897"> 
     56              <caret line="442" column="23" selection-start-line="442" selection-start-column="23" selection-end-line="442" selection-end-column="23" /> 
    6957              <folding> 
    7058                <element signature="imports" expanded="true" /> 
    71                 <element signature="method#init#0;class#javaClassifierComparison#0" /> 
    7259                <element signature="class#StartAndEndPoint#0;class#javaClassifierComparison#0" /> 
    7360                <element signature="class#Pair#0;class#javaClassifierComparison#0" /> 
    74                 <element signature="method#main#0;class#javaClassifierComparison#0" /> 
    75                 <element signature="method#Algorithm_HoughLinesP_Single#0;class#javaClassifierComparison#0" /> 
    76                 <element signature="method#Algorithm_HoughLinesP_Combo#0;class#javaClassifierComparison#0" /> 
    77                 <element signature="method#Algorithm_MorphologyOLD#0;class#javaClassifierComparison#0" /> 
    78                 <element signature="method#Algorithm_Morphology#0;class#javaClassifierComparison#0" /> 
     61                <element signature="method#init#0;class#javaClassifierComparison#0" /> 
    7962                <element signature="method#Classifier_LineCounter#0;class#javaClassifierComparison#0" /> 
    8063                <element signature="method#Classifier_ClusterDetection#0;class#javaClassifierComparison#0" /> 
     
    8366                <element signature="method#lineComparison#0;class#javaClassifierComparison#0" /> 
    8467                <element signature="method#ClusterCheck#0;class#javaClassifierComparison#0" /> 
     68                <element signature="method#Algorithm_MorphologyOLD2#0;class#javaClassifierComparison#0" /> 
     69                <element signature="method#Algorithm_MorphologyOLD#0;class#javaClassifierComparison#0" /> 
    8570              </folding> 
    8671            </state> 
     
    10287      <find>FILLED</find> 
    10388      <find>test</find> 
     89      <find>binarized</find> 
     90      <find>THRESHOLD_C</find> 
    10491    </findStrings> 
    10592  </component> 
     
    10996        <option value="$PROJECT_DIR$/../image-identification-terminal/javaImageClassifier.java" /> 
    11097        <option value="$PROJECT_DIR$/../image-identification-terminal/javaClassifierComparison" /> 
     98        <option value="$PROJECT_DIR$/../image-identification-terminal/javaClassifierComparison.java" /> 
    11199        <option value="$PROJECT_DIR$/image-identification-development/src/Main.java" /> 
    112         <option value="$PROJECT_DIR$/../image-identification-terminal/javaClassifierComparison.java" /> 
    113100        <option value="$PROJECT_DIR$/image-identification-development/src/MainMorph.java" /> 
    114101      </list> 
     
    191178      <window_info anchor="bottom" id="Message" order="0" /> 
    192179      <window_info anchor="bottom" id="Find" order="1" weight="0.32962137" /> 
    193       <window_info anchor="bottom" id="Run" order="2" weight="0.42316258" /> 
     180      <window_info anchor="bottom" id="Run" order="2" weight="0.2037862" /> 
    194181      <window_info anchor="bottom" id="Debug" order="3" weight="0.3997773" /> 
    195182      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> 
     
    207194      <window_info anchor="right" id="Maven" order="5" weight="0.3299298" /> 
    208195    </layout> 
     196    <layout-to-restore> 
     197      <window_info content_ui="combo" id="Project" order="0" weight="0.19783024" /> 
     198      <window_info id="Structure" order="1" side_tool="true" weight="0.25" /> 
     199      <window_info id="Designer" order="2" /> 
     200      <window_info id="UI Designer" order="3" /> 
     201      <window_info id="Favorites" order="4" side_tool="true" /> 
     202      <window_info anchor="bottom" id="Message" order="0" /> 
     203      <window_info anchor="bottom" id="Find" order="1" weight="0.32962137" /> 
     204      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.42316258" /> 
     205      <window_info anchor="bottom" id="Debug" order="3" weight="0.3997773" /> 
     206      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> 
     207      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> 
     208      <window_info anchor="bottom" id="TODO" order="6" /> 
     209      <window_info anchor="bottom" id="Version Control" order="7" /> 
     210      <window_info anchor="bottom" id="Terminal" order="8" weight="0.32962137" /> 
     211      <window_info anchor="bottom" id="Event Log" order="9" side_tool="true" weight="0.32962137" /> 
     212      <window_info anchor="bottom" id="Messages" order="10" weight="0.32962137" /> 
     213      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> 
     214      <window_info anchor="right" id="Ant Build" order="1" weight="0.24952137" /> 
     215      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" /> 
     216      <window_info anchor="right" id="Palette" order="3" /> 
     217      <window_info anchor="right" id="Palette&#9;" order="4" /> 
     218      <window_info anchor="right" id="Maven" order="5" weight="0.3299298" /> 
     219    </layout-to-restore> 
    209220  </component> 
    210221  <component name="antWorkspaceConfiguration"> 
     
    238249    <entry file="file://$PROJECT_DIR$/image-identification-development/src/Main.java"> 
    239250      <provider selected="true" editor-type-id="text-editor"> 
    240         <state relative-caret-position="557"> 
    241           <caret line="779" column="12" selection-start-line="779" selection-start-column="12" selection-end-line="779" selection-end-column="12" /> 
     251        <state relative-caret-position="2014"> 
     252          <caret line="760" selection-start-line="760" selection-end-line="760" /> 
    242253          <folding> 
    243254            <element signature="imports" expanded="true" /> 
     
    261272    <entry file="file://$PROJECT_DIR$/../image-identification-terminal/javaClassifierComparison.java"> 
    262273      <provider selected="true" editor-type-id="text-editor"> 
    263         <state relative-caret-position="225"> 
    264           <caret line="592" column="12" selection-start-line="592" selection-start-column="12" selection-end-line="592" selection-end-column="12" /> 
     274        <state relative-caret-position="6897"> 
     275          <caret line="442" column="23" selection-start-line="442" selection-start-column="23" selection-end-line="442" selection-end-column="23" /> 
    265276          <folding> 
    266277            <element signature="imports" expanded="true" /> 
    267             <element signature="method#init#0;class#javaClassifierComparison#0" /> 
    268278            <element signature="class#StartAndEndPoint#0;class#javaClassifierComparison#0" /> 
    269279            <element signature="class#Pair#0;class#javaClassifierComparison#0" /> 
    270             <element signature="method#main#0;class#javaClassifierComparison#0" /> 
    271             <element signature="method#Algorithm_HoughLinesP_Single#0;class#javaClassifierComparison#0" /> 
    272             <element signature="method#Algorithm_HoughLinesP_Combo#0;class#javaClassifierComparison#0" /> 
    273             <element signature="method#Algorithm_MorphologyOLD#0;class#javaClassifierComparison#0" /> 
    274             <element signature="method#Algorithm_Morphology#0;class#javaClassifierComparison#0" /> 
     280            <element signature="method#init#0;class#javaClassifierComparison#0" /> 
    275281            <element signature="method#Classifier_LineCounter#0;class#javaClassifierComparison#0" /> 
    276282            <element signature="method#Classifier_ClusterDetection#0;class#javaClassifierComparison#0" /> 
     
    279285            <element signature="method#lineComparison#0;class#javaClassifierComparison#0" /> 
    280286            <element signature="method#ClusterCheck#0;class#javaClassifierComparison#0" /> 
     287            <element signature="method#Algorithm_MorphologyOLD2#0;class#javaClassifierComparison#0" /> 
     288            <element signature="method#Algorithm_MorphologyOLD#0;class#javaClassifierComparison#0" /> 
    281289          </folding> 
    282290        </state> 
     
    285293    <entry file="file://$PROJECT_DIR$/image-identification-development/src/MainMorph.java"> 
    286294      <provider selected="true" editor-type-id="text-editor"> 
    287         <state relative-caret-position="383"> 
    288           <caret line="236" column="54" selection-start-line="236" selection-start-column="54" selection-end-line="236" selection-end-column="54" /> 
     295        <state relative-caret-position="106"> 
     296          <caret line="1351" column="52" selection-start-line="1351" selection-start-column="52" selection-end-line="1351" selection-end-column="52" /> 
    289297          <folding> 
    290298            <element signature="imports" expanded="true" /> 
    291299            <element signature="method#imageViewer#0;class#MainMorph#0" /> 
    292             <element signature="e#14232#16729#1" /> 
    293             <element signature="e#16814#18826#1" /> 
    294             <element signature="e#18895#21536#1" /> 
    295             <element signature="e#21620#27308#1" /> 
    296             <element signature="e#27393#31396#1" /> 
    297             <element signature="e#31464#32641#1" /> 
    298             <element signature="e#32710#36690#1" /> 
    299             <element signature="e#36800#48520#1" /> 
    300             <element signature="e#45567#45616#0" /> 
    301             <element signature="e#48614#59515#1" /> 
    302             <element signature="e#59847#68195#1" /> 
    303             <element signature="e#61117#61159#0" /> 
    304300          </folding> 
    305301        </state> 
  • other-projects/is-sheet-music-encore/trunk/image-identification-dev-02/image-identification-development/src/Main.java

    r33455 r33589  
    111111    static int STANDARD_DEVIATION_THRESHOLD = 6; 
    112112    static int MINLINECOUNT                 = 40; 
    113     static int MAXLINEGAP                   = 1;  //4 
     113    static int MAXLINEGAP                   = 1; 
    114114    static double THRESHOLD_C               = 4; 
    115115    static double SLOPEGRADIENT             = 0.02; //0.02 
     
    757757            //!!!!!!!!!!!!!!!!!!!!!!!!!!!NOTNOT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    758758            //coo.31924062612282-9.png 8   lines 
    759             //String default_file = hiresDirectory+ "MU/SheetMusic/mdp.39015096400919-9.png"; 
     759            String default_file = hiresDirectory+ "MU/SheetMusic/mdp.39015096400919-9.png"; 
     760            //String default_file = hiresDirectory+ "MU/SheetMusic/coo.31924062612282-9.png"; 
    760761 
    761762            //String default_file = hiresDirectory+ "MU/SheetMusic/mdp.39015096402204-2.png"; 
     
    778779            //String default_file = "TestImages/SheetMusic01.png"; 
    779780            //String default_file = "TestImages/SheetMusic02.png"; 
    780             String default_file = "TestImages/vLine.png"; 
     781            //String default_file = "TestImages/vLine.png"; 
    781782            String filename = ((args.length > 0) ? args[0] : default_file); 
    782783            File file = new File(filename); 
     
    791792            // Edge detection 
    792793 
    793             Imgproc.adaptiveThreshold(original, edgesDetected,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
     794            Imgproc.adaptiveThreshold(original, edgesDetected,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 1001, THRESHOLD_C); 
    794795            //TEST PARAMETERSImgproc.adaptiveThreshold(original, edgesDetected,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 531,1); 
    795796 
    796797 
    797798//            //IGNORE BORDERS OF IMAGE (using crop) 
    798 //            Imgproc.adaptiveThreshold(original, mid,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, 2); 
     799//            Imgproc.adaptiveThreshold(original, mid,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 1001, 2); 
    799800//            double maxX = mid.size().width; 
    800801//            double maxY = mid.size().height; 
    801 //            Point cp1 = new Point(maxX/10, maxY/10); 
     802//            Point cp1 = new Point(maxX/5, maxY/5); 
    802803//            Point cp2 = new Point(maxX - cp1.x, maxY -cp1.y); 
    803804//            Rect rectCrop = new Rect(cp1, cp2); 
    804805//            edgesDetected = mid.submat(rectCrop); 
    805806 
    806  
     807//            System.out.println("Width: " + edgesDetected.width() + " Height: " + edgesDetected.height()); 
    807808            //****************MORPHOLOGY**************************************************************************************** 
    808809            //ADDIOTIONAL FILTERING TO STOP STREAKS 
     
    833834 
    834835            double minLineLength = edgesDetectedRGB.size().width/8; 
    835  
     836            imwrite("houghtest-bin.jpg", edgesDetectedRGB); 
    836837            Imgproc.HoughLinesP(edgesDetected, linesP, 1, Math.PI / 720, HOUGHLINEP_THRESHOLD, minLineLength,MAXLINEGAP); // runs the actual detection 
    837838            //System.out.println("Before Gradient Filtering num lines: " + linesP.rows()); 
     
    856857            //File filenameTest = new File("TestImages/NotSheetMusic02.png"); 
    857858            //BufferedImage i = ImageIO.read(filenameTest); 
    858             BufferedImage toBeClassifiedImg = toBufferedImage(edgesDetectedRGB); 
     859            //BufferedImage toBeClassifiedImg = toBufferedImage(edgesDetectedRGB); 
    859860 
    860861 
    861862            //Display Results 
     863 
     864            imwrite("houghtest-lines.jpg", edgesDetectedRGB); 
    862865            //HighGui.imshow("Source", original); 
    863866            //HighGui.imshow("Just Edges", justEdges); //TESTING 
    864867 
    865  
    866             HighGui.imshow("LINESFOUND", edgesDetectedRGB); 
    867             HighGui.resizeWindow("LINESFOUND", 1000,1000); 
    868              
    869             HighGui.imshow("CLUSTERSFOUND", clustersFoundRGB); 
    870             HighGui.resizeWindow("CLUSTERSFOUND", 1000,1000); 
     868//            HighGui.namedWindow("LINESFOUND", HighGui.WINDOW_AUTOSIZE); 
     869//            HighGui.imshow("LINESFOUND", edgesDetectedRGB); 
     870//            HighGui.resizeWindow("LINESFOUND", 1000,1000); 
     871// 
     872// 
     873//            HighGui.imshow("CLUSTERSFOUND", clustersFoundRGB); 
     874//            HighGui.namedWindow("CLUSTERSFOUND", HighGui.WINDOW_AUTOSIZE); 
     875//            HighGui.resizeWindow("CLUSTERSFOUND", 1000,1000); 
    871876 
    872877            //HighGui.imshow("Detected Lines (in red) - negative", edgesDetectedRGBProb); 
     
    874879            System.out.println("LINE COUNT RESULT:   " +  ClassifierLineCount(horizontalLineCount) + '\t' +"LinesFound: " + horizontalLineCount); //COUNT OF LINES CLASSIFICATION 
    875880            //System.out.println("LINE CLUSTER RESULT: " +  ClassifierLineClusterOLD(toBeClassifiedImg).get(0) + '\t' + "LinesFound: " + ClassifierLineClusterOLD(toBeClassifiedImg).get(1) + '\t' + "ClustersFound: " + ClassifierLineClusterOLD(toBeClassifiedImg).get(2)); 
    876             System.out.println("NEW CLUSTER RESULTS: " +  ClassifierLineClusterPt(pointArrayList,clustersFoundRGB).get(0) + '\t' + "LinesFound: " + horizontalLineCount + '\t' + "ClustersFound: " + ClassifierLineClusterPt(pointArrayList,clustersFoundRGB).get(1)); 
     881            //System.out.println("NEW CLUSTER RESULTS: " +  ClassifierLineClusterPt(pointArrayList,clustersFoundRGB).get(0) + '\t' + "LinesFound: " + horizontalLineCount + '\t' + "ClustersFound: " + ClassifierLineClusterPt(pointArrayList,clustersFoundRGB).get(1)); 
    877882            //System.out.println(ClassifierLineClusterPt(pointArrayList, clustersFoundRGB)); 
    878883 
     
    880885 
    881886            // Wait and Exit 
    882             HighGui.waitKey(); 
     887            //HighGui.waitKey(); 
    883888            System.exit(0); 
    884889        } 
  • other-projects/is-sheet-music-encore/trunk/image-identification-dev-02/image-identification-development/src/MainMorph.java

    r33458 r33589  
    6666 
    6767import static org.opencv.core.Core.FILLED; 
     68import static org.opencv.core.Core.calcCovarMatrix; 
    6869import static org.opencv.core.CvType.CV_8UC3; 
    6970import static org.opencv.highgui.HighGui.createJFrame; 
     
    193194            //Variables 
    194195            System.out.println("Running Code version: " + CODE_VERSION + " Image Version: " +IMAGE_VERSION); 
    195             Mat mid = new Mat(); 
    196196            Mat edgesDetectedRGB = new Mat(); 
    197197            Mat clustersFoundRGB = new Mat(); 
     
    209209            //String default_file =hiresDirectory+"BK/NotSheetMusic/aeu.ark+=13960=t2q53nq6w-6.png"; 
    210210            //String default_file =hiresDirectory+"BK/NotSheetMusic/aeu.ark+=13960=t9z03w65z-4.png"; 
     211            //String default_file =hiresDirectory+"BK/NotSheetMusic/loc.ark+=13960=t50g4443d-5.png"; 
    211212            //String default_file =hiresDirectory+"MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-1.png"; 
    212213            //String default_file =hiresDirectory+"MU/SheetMusic/emu.010001066823-9.png"; 
     
    234235            //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-1.png";  //Image evaluation 
    235236            //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-2.png";  //large numbers 
     237            //String default_file = hiresDirectory+ "MU/SheetMusic/mdp.39015096400919-9.png"; 
    236238            //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-3.png"; 
    237             String default_file = hiresDirectory+"/MU/SheetMusic/mdp.39015080921409-9.png"; 
     239            //String default_file = hiresDirectory+"/MU/SheetMusic/mdp.39015080921409-9.png"; 
    238240            //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-4.png"; 
    239241            //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-5.png"; 
     
    242244            //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-8.png"; 
    243245            //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-9.png"; 
     246            String default_file = hiresDirectory+"/MU/SheetMusic/mdp.39015096398899-4.png"; 
    244247 
    245248 
     
    260263            Mat original = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE); 
    261264            System.out.println("Width: " + original.width() + " Height: " + original.height()); 
    262             Mat binarizedOriginal = original.clone(); 
     265            Mat binarized = original.clone(); 
    263266             
    264             Imgproc.adaptiveThreshold(original, binarizedOriginal,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
     267            //Imgproc.adaptiveThreshold(original, binarized,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
    265268            //TEST PARAMETERSImgproc.adaptiveThreshold(original, edgesDetected,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 531,1); 
    266269            //Imgproc.threshold(original,original, 127, 255, Imgproc.THRESH_BINARY); 
    267  
     270            //************************ 
     271            //Argument Setup 
     272            //************************ 
     273            int tempvariable = 0; 
     274            if (tempvariable ==1){ 
     275                Imgproc.adaptiveThreshold(original, binarized, 255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C, Imgproc.THRESH_BINARY_INV, 1001, 5); 
     276            } 
     277            else { 
     278 
     279                int borderIgnoreAmount = 0; 
     280                double divisor; 
     281                switch (borderIgnoreAmount) { 
     282                    case 5: 
     283                        divisor = 40; 
     284                        break; 
     285                    case 10: 
     286                        divisor = 20; 
     287                        break; 
     288                    case 20: 
     289                        divisor = 10; 
     290                        break; 
     291                    case 40: 
     292                        divisor = 5; 
     293                        break; 
     294                    case 0: 
     295                        divisor = -1; 
     296                        break; 
     297                    default: 
     298                        divisor = -1; 
     299                } 
     300                if (divisor != -1) { 
     301                    Mat mid = new Mat(); 
     302                    Imgproc.adaptiveThreshold(original, mid, 255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C, Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
     303                    double maxX = mid.size().width; 
     304                    double maxY = mid.size().height; 
     305                    Point cp1 = new Point(maxX / divisor, maxY / divisor); 
     306                    Point cp2 = new Point(maxX - cp1.x, maxY - cp1.y); 
     307                    Rect rectCrop = new Rect(cp1, cp2); 
     308                    binarized = mid.submat(rectCrop); 
     309                } else { 
     310                    Imgproc.adaptiveThreshold(original, binarized, 255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C, Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
     311                } 
     312 
     313                System.out.println("Width: " + binarized.width() + " Height: " + binarized.height()); 
     314            } 
    268315 
    269316            //****************MORPHOLOGY**************************************************************************************** 
     
    276323            //dynamic morphology?? 
    277324            if(CODE_VERSION == 1) { 
    278                 int hori = binarizedOriginal.width(); 
    279                 int vert = binarizedOriginal.height(); 
     325                int hori = binarized.width(); 
     326                int vert = binarized.height(); 
    280327                //Find ratio between 100 and width and 100 and height 
    281328                int divX = hori/10; 
     
    284331                int sizeY = (vert/divY) * 10; 
    285332 
    286                 Mat test = binarizedOriginal.clone(); 
     333                Mat test = binarized.clone(); 
    287334                imageViewer("Original", test); 
    288335 
     
    326373 
    327374                //MAKE SURE BLACK & WHITE 
    328                 Mat test = binarizedOriginal.clone(); 
     375                Mat test = binarized.clone(); 
    329376                imageViewer("00 Binarized Original", test); 
    330377 
     
    366413            //Tutorial/Demo Code 
    367414            if (CODE_VERSION == 3) { 
    368                 Mat horizontal = binarizedOriginal.clone(); 
    369                 Mat vertical = binarizedOriginal.clone(); 
     415                Mat horizontal = binarized.clone(); 
     416                Mat vertical = binarized.clone(); 
    370417                // Specify size on horizontal axis 
    371418                int horizontal_size = horizontal.cols() / 50; 
     
    420467                imageViewer("original", original); 
    421468 
    422                 Mat test = binarizedOriginal.clone(); 
    423                 Mat pre = binarizedOriginal.clone(); 
     469                Mat test = binarized.clone(); 
     470                Mat pre = binarized.clone(); 
    424471                Mat dst = new Mat(); 
    425472 
     
    534581            //Better morphology attempt - dynamic 
    535582            if(CODE_VERSION == 5) { 
    536                 int hori = binarizedOriginal.width(); 
    537                 int vert = binarizedOriginal.height(); 
     583                int hori = binarized.width(); 
     584                int vert = binarized.height(); 
    538585                //Find ratio between 100 and width and 100 and height 
    539586                int sizeX100 = 10 * (hori/68); 
     
    551598                imageViewer("original", original); 
    552599 
    553                 Mat test = binarizedOriginal.clone(); 
     600                Mat test = binarized.clone(); 
    554601                imageViewer("00 Inverse Binarized Original", test); 
    555602 
     
    643690                imageViewer("original", original); 
    644691 
    645                 Mat src = binarizedOriginal.clone(); 
    646                 Mat test = binarizedOriginal.clone(); 
     692                Mat src = binarized.clone(); 
     693                Mat test = binarized.clone(); 
    647694                Mat mask = new Mat(); 
    648695                Mat dst = new Mat(); 
     
    729776                imageViewer("original", original); 
    730777 
    731                 Mat test = binarizedOriginal.clone(); 
     778                Mat test = binarized.clone(); 
    732779 
    733780 
     
    738785                //Large Object Removal 
    739786                //************************************ 
    740                 Mat srcLOR = binarizedOriginal.clone(); 
     787                Mat srcLOR = binarized.clone(); 
    741788                Mat maskLOR = new Mat(); 
    742789                Mat dstLOR = new Mat(); 
     
    9681015                    //Imgproc.adaptiveThreshold(original1, original,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
    9691016 
    970                     Mat test = binarizedOriginal.clone(); 
     1017                    Mat test = binarized.clone(); 
    9711018                    //************************************ 
    9721019                    //Large Object Removal 
    9731020                    //************************************ 
    974                     Mat srcLOR = binarizedOriginal.clone(); 
     1021                    Mat srcLOR = binarized.clone(); 
    9751022                    Mat maskLOR = new Mat(); 
    9761023                    Mat dstLOR = new Mat(); 
     
    11581205            //Reset after david chat 
    11591206            if(CODE_VERSION == 9){ 
     1207                int areaCounter=0; 
    11601208                //Display Original 
    11611209                imageViewer("original", original); 
    1162                 imageViewer("000 Inverse Binarized Original", binarizedOriginal); 
     1210                imageViewer("000 Inverse Binarized Original", binarized); 
    11631211 
    11641212 
     
    11661214                //1. Large Object Remover 
    11671215                //************************************ 
    1168                 Mat srcLOR = binarizedOriginal.clone(); 
     1216                Mat srcLOR = binarized.clone(); 
    11691217                Mat maskLOR = new Mat(); 
    11701218                Mat dstLOR = new Mat(); 
     
    11761224 
    11771225                //Heal the large items 
    1178                 Mat healLOR = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(25,25)); 
     1226                Mat healLOR = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(25,25)); //5,5 
    11791227                Imgproc.morphologyEx(maskLOR,maskLOR, Imgproc.MORPH_CLOSE, healLOR); 
    11801228                imageViewer("002 heal objects in mask", maskLOR); 
    11811229 
    11821230                //IsolateLarge 
    1183                 Mat isolateLargeLOR = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(30,30)); 
     1231                Mat isolateLargeLOR = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(30,30)); //8,8 
    11841232                Imgproc.morphologyEx(maskLOR,maskLOR, Imgproc.MORPH_OPEN, isolateLargeLOR); 
    11851233                imageViewer("003 Isolate large", maskLOR); 
     
    12541302 
    12551303                //4. Classify like line clusters. 
    1256                 Mat base = binarizedOriginal.clone(); 
     1304                Mat base = binarized.clone(); 
    12571305                //*********************************** 
    12581306                //3. Isolate straight lines 
    12591307                //*********************************** 
    12601308                //Heal lines 
    1261                 Mat healISL = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(82,1)); 
     1309                Mat healISL = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(86,1)); 
    12621310                Imgproc.morphologyEx(dstLOR,base, Imgproc.MORPH_OPEN, healISL); 
    12631311                imageViewer("202 heal objects in mask", base); 
     
    13101358                        System.out.println("i:"+ i + " Height: " + boundRect[i].height); 
    13111359                        if(boundRect[i].width > 300){ 
     1360                            areaCounter++; 
    13121361                            System.out.println("i:"+ i + " Width: " +  boundRect[i].width); 
    13131362                            Imgproc.rectangle(rectOutput, boundRect[i].tl(), boundRect[i].br(), new Scalar(255, 0, 0), 20); 
     
    13181367 
    13191368                imageViewer("4000 Rect found", rectOutput); 
     1369                System.out.println(areaCounter); 
    13201370 
    13211371 
     
    13271377                Pair returnVariables = new Pair(); 
    13281378                int areaCounter=0; 
     1379 
     1380 
    13291381                //Mat original = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE); 
    1330                 //Mat binarizedOriginal = original.clone(); 
    1331                 //Imgproc.adaptiveThreshold(original, binarizedOriginal,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
     1382                //Mat binarized = original.clone(); 
     1383                //Mat mid = new Mat(); 
     1384                //if(borderCrop > 0){ 
     1385                    //Imgproc.adaptiveThreshold(original, mid,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, 2); 
     1386                    //double maxX = mid.size().width; 
     1387                    //double maxY = mid.size().height; 
     1388                    //Point cp1 = new Point(maxX/10, maxY/10); 
     1389                    //Point cp2 = new Point(maxX - cp1.x, maxY -cp1.y); 
     1390                    //Rect rectCrop = new Rect(cp1, cp2); 
     1391                    //binarized = mid.submat(rectCrop); 
     1392                //} 
     1393                //else{ 
     1394                //Imgproc.adaptiveThreshold(original, binarized,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
     1395                //} 
     1396 
     1397 
    13321398                try{ 
    13331399                    //************************************ 
    13341400                    //1. Large Object Remover 
    13351401                    //************************************ 
    1336                     Mat srcLOR = binarizedOriginal.clone(); 
     1402                    Mat srcLOR = binarized.clone(); 
    13371403                    Mat maskLOR = new Mat(); 
    13381404                    Mat dstLOR = new Mat(); 
     
    13531419                    srcLOR.copyTo(dstLOR, maskLOR); 
    13541420 
    1355                     Mat base = binarizedOriginal.clone(); 
     1421                    Mat base = binarized.clone(); 
    13561422                    //*********************************** 
    13571423                    //3. Isolate straight lines 
  • other-projects/is-sheet-music-encore/trunk/image-identification-terminal/Makefile

    r33449 r33589  
    3636     
    3737testrun-classifier-single-combo: 
    38     ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU/SheetMusic/coo.31924062612282-9.png combo logSingle.txt -singleNew 
     38    ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/image-identification-terminal/TestImages/SheetMusic02.png combo logSingle.txt -singleNew 40  
    3939    echo "Displaying javaImageClassifier output" 
    4040        #Calculate the Accuracy of the classifier 
  • other-projects/is-sheet-music-encore/trunk/image-identification-terminal/javaAccuracyCalculator.java

    r33439 r33589  
    2828                float falseAccuracyRate  =0; 
    2929                float overallAccuracyRate=0; 
     30                String notApplicable = "N/A"; 
    3031                // 
    3132                int sheetMusicCount = 0; 
     
    9394                } 
    9495                else if (sheetMusicCount == 0) { 
     96                    trueAccuracyRate = -1; 
    9597                    overallAccuracyRate = falseAccuracyRate; 
    9698                } 
    9799                else if(notSheetMusicCount == 0) { 
     100                    falseAccuracyRate = -1; 
    98101                    overallAccuracyRate = trueAccuracyRate; 
    99102                } 
     
    102105                    System.out.println("There is nothing to compare"); 
    103106                } 
    104                  
    105                 fw.write("Date: " + d.toString() + '\n' 
    106                     + "Classifier: " + classifierType + '\n'  
    107                     + "truePositive: "  + truePositive + '\n'  
    108                     + "falseNegative: " + falseNegative + '\n' 
    109                     + "falsePositve: "  + falsePositive + '\n'   
    110                     + "trueNegative: "  + trueNegative + '\n' 
    111                     + "SheetMusicAccuracyRate: "    + trueAccuracyRate + "%" + '\n' 
    112                     + "NotSheetMusicAccuracyRate: " + falseAccuracyRate + "%" + '\n' 
    113                     + "OverallAccuracyRate: "       + overallAccuracyRate + "%" + '\n' + 
    114                     "****************************************************************" + '\n');      
     107                if(falseAccuracyRate ==-1){ 
     108                    fw.write("Date: " + d.toString() + '\n' 
     109                        + "Classifier: " + classifierType + '\n'  
     110                        + "truePositive: "  + truePositive + '\n'  
     111                        + "falseNegative: " + falseNegative + '\n' 
     112                        + "falsePositve: "  + falsePositive + '\n'   
     113                        + "trueNegative: "  + trueNegative + '\n' 
     114                        + "SheetMusicAccuracyRate: "    + trueAccuracyRate + "%" + '\n' 
     115                        + "NotSheetMusicAccuracyRate: " + notApplicable + '\n' 
     116                        + "OverallAccuracyRate: "       + overallAccuracyRate + "%" + '\n');                     
     117                } 
     118                else if(trueAccuracyRate == -1){     
     119                    fw.write("Date: " + d.toString() + '\n' 
     120                        + "Classifier: " + classifierType + '\n'  
     121                        + "truePositive: "  + truePositive + '\n'  
     122                        + "falseNegative: " + falseNegative + '\n' 
     123                        + "falsePositve: "  + falsePositive + '\n'   
     124                        + "trueNegative: "  + trueNegative + '\n' 
     125                        + "SheetMusicAccuracyRate: "    + notApplicable + '\n' 
     126                        + "NotSheetMusicAccuracyRate: " + falseAccuracyRate + "%" + '\n' 
     127                        + "OverallAccuracyRate: "       + overallAccuracyRate + "%" + '\n');                     
     128                } 
     129                else{ 
     130                    fw.write("Date: " + d.toString() + '\n' 
     131                        + "Classifier: " + classifierType + '\n'  
     132                        + "truePositive: "  + truePositive + '\n'  
     133                        + "falseNegative: " + falseNegative + '\n' 
     134                        + "falsePositve: "  + falsePositive + '\n'   
     135                        + "trueNegative: "  + trueNegative + '\n' 
     136                        + "SheetMusicAccuracyRate: "    + trueAccuracyRate + "%" + '\n' 
     137                        + "NotSheetMusicAccuracyRate: " + falseAccuracyRate + "%" + '\n' 
     138                        + "OverallAccuracyRate: "       + overallAccuracyRate + "%" + '\n'); 
     139                }        
    115140                buf.close(); 
    116141                fw.close();                              
  • other-projects/is-sheet-music-encore/trunk/image-identification-terminal/javaClassifierComparison.java

    r33458 r33589  
    7272    static double THRESHOLD_AREA_COUNT; 
    7373 
    74 //******************************************************************************************** 
    75 //CLASSES 
    76 //******************************************************************************************** 
    77      
    78     //Sets globals based off properties file 
    79     public static void init(){ 
    80         try{ 
    81             Properties config = new Properties(); 
    82             FileInputStream input = new FileInputStream("configClassifierComparison.properties"); 
    83             config.load(input); 
    84             CLASSIFIER_HOUGHLINESP_MIN =    Integer.parseInt(config.getProperty("CLASSIFIER_HOUGHLINESP_MIN")); 
    85             CLASSIFIER_HOUGHLINESP_MAX =    Integer.parseInt(config.getProperty("CLASSIFIER_HOUGHLINESP_MAX")); 
    86             HOUGHLINEP_THRESHOLD =          Integer.parseInt(config.getProperty("HOUGHLINEP_THRESHOLD"));  
    87             STANDARD_DEVIATION_THRESHOLD =  Integer.parseInt(config.getProperty("STANDARD_DEVIATION_THRESHOLD")); 
    88             MINLINECOUNT =                  Integer.parseInt(config.getProperty("MINLINECOUNT")); 
    89             MAXLINEGAP =                    Integer.parseInt(config.getProperty("MAXLINEGAP")); 
    90             THRESHOLD_C =                   Double.parseDouble(config.getProperty("THRESHOLD_C")); 
    91             SLOPEGRADIENT =                 Double.parseDouble(config.getProperty("SLOPEGRADIENT")); 
    92             CLUSTER_DISTANCE_MAX =          Double.parseDouble(config.getProperty("CLUSTER_DISTANCE_MAX")); 
    93             CLUSTER_DISTANCE_MIN =          Double.parseDouble(config.getProperty("CLUSTER_DISTANCE_MIN")); 
    94             THRESHOLD_AREA_SIZE =           Double.parseDouble(config.getProperty("THRESHOLD_AREA_SIZE")); 
    95             THRESHOLD_AREA_COUNT =          Double.parseDouble(config.getProperty("THRESHOLD_AREA_COUNT")); 
    96         } 
    97         catch(Exception e){ 
    98             e.printStackTrace(); 
    99         } 
    100     } 
    101      
     74    //****************** 
     75    //CLASSES 
     76    //****************** 
    10277    static public class StartAndEndPoint { 
    10378        //PRIVATES 
     
    161136    } 
    162137 
     138    //****************** 
     139    //TRIGGERS 
     140    //****************** 
     141    /**Sets globals based off properties file*/ 
     142    public static void init(){ 
     143        try{ 
     144            Properties config = new Properties(); 
     145            FileInputStream input = new FileInputStream("configClassifierComparison.properties"); 
     146            config.load(input); 
     147            CLASSIFIER_HOUGHLINESP_MIN =    Integer.parseInt(config.getProperty("CLASSIFIER_HOUGHLINESP_MIN")); 
     148            CLASSIFIER_HOUGHLINESP_MAX =    Integer.parseInt(config.getProperty("CLASSIFIER_HOUGHLINESP_MAX")); 
     149            HOUGHLINEP_THRESHOLD =          Integer.parseInt(config.getProperty("HOUGHLINEP_THRESHOLD")); 
     150            STANDARD_DEVIATION_THRESHOLD =  Integer.parseInt(config.getProperty("STANDARD_DEVIATION_THRESHOLD")); 
     151            MINLINECOUNT =                  Integer.parseInt(config.getProperty("MINLINECOUNT")); 
     152            MAXLINEGAP =                    Integer.parseInt(config.getProperty("MAXLINEGAP")); 
     153            THRESHOLD_C =                   Double.parseDouble(config.getProperty("THRESHOLD_C")); 
     154            SLOPEGRADIENT =                 Double.parseDouble(config.getProperty("SLOPEGRADIENT")); 
     155            CLUSTER_DISTANCE_MAX =          Double.parseDouble(config.getProperty("CLUSTER_DISTANCE_MAX")); 
     156            CLUSTER_DISTANCE_MIN =          Double.parseDouble(config.getProperty("CLUSTER_DISTANCE_MIN")); 
     157            THRESHOLD_AREA_SIZE =           Double.parseDouble(config.getProperty("THRESHOLD_AREA_SIZE")); 
     158            THRESHOLD_AREA_COUNT =          Double.parseDouble(config.getProperty("THRESHOLD_AREA_COUNT")); 
     159        } 
     160        catch(Exception e){ 
     161            e.printStackTrace(); 
     162        } 
     163    } 
     164    /***/ 
    163165    public static void main(String[] args) { 
    164166        init(); 
    165167        try { 
    166168         
    167             if (args.length != 3) { 
     169            if (args.length < 3) { 
    168170                System.out.println("Usage: imageClassifier <inputFilename> <classifierType> <outputFilename>"); 
     171                System.out.println("+ (Optional)<BorderIgnoreAmount[0,5, 10, 20, 40]>"); 
    169172            } else { 
    170173                Pair algorithmResult = new Pair(); 
    171  
    172174                Boolean result = null; 
    173175                String result_cluster = ""; 
     
    176178                String outputFilename = args[2]; 
    177179                Boolean enableLineClustering = null; 
     180 
    178181                //Prep Writing output to disc 
    179182                File log = new File(outputFilename); 
    180183                FileWriter fileWriter = new FileWriter(log, true); 
    181184                BufferedWriter bw = new BufferedWriter(fileWriter); 
    182                 //Execute classifierType defined from arguement 
    183  
    184185                File imgCheck = new File(imageFilename); 
    185186                if(!imgCheck.exists()){System.err.println("Image not found: "+ imageFilename);} 
    186187 
    187                 //Split output by tab for processing in next java program 
    188                 //imageFilename = 1, result = 3, classifierType = 4 
    189                  
     188// 
     189 
     190 
     191                //Arguement Preps 
     192                int borderIgnoreAmount; 
     193                if(args.length >= 4){borderIgnoreAmount =Integer.parseInt(args[3]);} 
     194                else {borderIgnoreAmount=-1;} 
     195 
     196                //imageFilename = 1, result = 3, classifierType = 4 ????? 
    190197                switch (classifierType) { 
     198                    //Splits output by tab for processing in next java program 
    191199                    case "count": 
    192200                        enableLineClustering = false; 
    193                         algorithmResult = Algorithm_HoughLinesP_Single(imageFilename, enableLineClustering); 
     201                        algorithmResult = Algorithm_HoughLinesP_Single(imageFilename, enableLineClustering, borderIgnoreAmount); 
    194202                        bw.write("Filename:" + '\t' + imageFilename + '\t' + "Classified as:" + '\t' + algorithmResult.getBoolean() + '\t' + "Number of lines:" + '\t' + algorithmResult.getInteger() + '\t' + classifierType + '\n'); 
    195203                        break; 
    196204                    case "cluster": 
    197205                        enableLineClustering = true; 
    198                         algorithmResult = Algorithm_HoughLinesP_Single(imageFilename, enableLineClustering); 
     206                        algorithmResult = Algorithm_HoughLinesP_Single(imageFilename, enableLineClustering, borderIgnoreAmount); 
    199207                        bw.write("Filename:" + '\t' + imageFilename + '\t' + "Classified as:" + '\t' + algorithmResult.getBoolean() + '\t' + "Number of lines:" + '\t' + algorithmResult.getInteger() + '\t' + classifierType + '\n'); 
    200208                        break; 
    201209                    case "combo": 
    202                         algorithmResult = Algorithm_HoughLinesP_Combo(imageFilename); 
     210                        algorithmResult = Algorithm_HoughLinesP_Combo(imageFilename, borderIgnoreAmount); 
    203211                        bw.write("Filename:" + '\t' + imageFilename + '\t' + "Classified as:" + '\t' + algorithmResult.getBoolean() + '\t' + "Number of lines:" + '\t' + algorithmResult.getInteger() + '\t' + classifierType + '\n'); 
    204212                        break; 
    205213                    case "morphology": 
    206                         algorithmResult = Algorithm_Morphology(imageFilename); 
     214                        algorithmResult = Algorithm_Morphology(imageFilename, borderIgnoreAmount); 
    207215                        bw.write("Filename:" + '\t' + imageFilename + '\t' + "Classified as:" + '\t' + algorithmResult.getBoolean() + '\t' + "Number of areas:" + '\t' + algorithmResult.getInteger() + '\t' + classifierType + '\n'); 
    208216                        break; 
     
    210218                        System.out.println("unknown algorithm"); 
    211219                        break; 
    212                 }      
    213                  
     220                } 
    214221                bw.close(); 
    215222            } 
     
    222229    //ALGORITHM FUNCTIONS 
    223230    //****************** 
    224     private static Pair Algorithm_HoughLinesP_Single(String filename, Boolean enableLineClusterDetection){ 
     231    private static Pair Algorithm_HoughLinesP_Single(String filename, Boolean enableLineClusterDetection, int borderIgnoreAmount){ 
     232        //****************EXPLANATION************************************************** 
     233        // 
     234        //Load an image in greyscale 
     235        //Additional matrix to hold results of line detection 
     236        //Inversed Binarization of image 
     237        //Detect lines in image 
     238        //Go thru every line detected and check its gradient is less than SLOPEGRADIENT 
     239        // 
     240        //****************EXPLANATION************************************************** 
    225241        System.loadLibrary(Core.NATIVE_LIBRARY_NAME); 
    226242        Boolean isSheetMusic = null; 
     
    235251            ArrayList<StartAndEndPoint> pointArrayList = new ArrayList<StartAndEndPoint>(); 
    236252 
    237             //****************EXPLANATION************************************************** 
    238             // 
    239             //Load an image in greyscale 
    240             //Additional matrix to hold results of line detection 
    241             //Inversed Binarization of image 
    242             //Detect lines in image 
    243             //Go thru every line detected and check its gradient is less than SLOPEGRADIENT 
    244             // 
    245             //****************EXPLANATION************************************************** 
    246  
    247253            Mat original = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE); 
     254             
     255            Mat binarized = original.clone(); 
     256            int blockSize = binarized.height()/3; 
     257            //BlockSize must be blockSize % 2 == 1 && blockSize > 1 
     258            while (!(blockSize % 2 == 1 && blockSize > 1)) { 
     259                blockSize++; 
     260            } 
     261             
     262             
     263            System.out.println("Width: " + binarized.width() + " Height: " + binarized.height()); 
     264            //************************ 
     265            //Argument Setup 
     266            //************************ 
     267            double divisor; 
     268            switch (borderIgnoreAmount){ 
     269                case 5: 
     270                    divisor = 40; 
     271                    break; 
     272                case 10: 
     273                    divisor = 20; 
     274                    break; 
     275                case 20: 
     276                    divisor = 10; 
     277                    break; 
     278                case 40: 
     279                    divisor = 5; 
     280                    break; 
     281                case -1: 
     282                    divisor = -1; 
     283                    break; 
     284                default: divisor = -1; 
     285            } 
     286            if(divisor != -1 ) { 
     287                Mat mid = new Mat(); 
     288                Imgproc.adaptiveThreshold(original, mid,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, blockSize, THRESHOLD_C); 
     289                //Remove borders from Mat 
     290                //Get width and 
     291                double maxX = mid.size().width; 
     292                double maxY = mid.size().height; 
     293                Point cp1 = new Point(maxX / divisor, maxY / divisor); 
     294                Point cp2 = new Point(maxX - cp1.x, maxY - cp1.y); 
     295                Rect rectCrop = new Rect(cp1, cp2); 
     296                binarized = mid.submat(rectCrop); 
     297            } 
     298            else{Imgproc.adaptiveThreshold(original, binarized,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, blockSize, THRESHOLD_C);} 
     299            System.out.println("Width: " + binarized.width() + " Height: " + binarized.height());  
     300            edgesDetected = binarized.clone(); 
     301             
     302             
    248303            Mat linesP = new Mat(); //will hold the results of the detection 
    249             Imgproc.adaptiveThreshold(original, edgesDetected,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV,15, THRESHOLD_C); 
    250304            double minLineLength = edgesDetected.size().width/8; 
    251305            Imgproc.HoughLinesP(edgesDetected, linesP, 1, Math.PI / 720, HOUGHLINEP_THRESHOLD, minLineLength, MAXLINEGAP); 
     
    274328        return returnVariables; 
    275329    } 
    276     private static Pair Algorithm_HoughLinesP_Combo(String filename){ 
     330    private static Pair Algorithm_HoughLinesP_Combo(String filename, int borderIgnoreAmount){ 
     331        //****************EXPLANATION************************************************** 
     332        // 
     333        //Load an image in greyscale 
     334        //Additional matrix to hold results of line detection 
     335        //Inversed Binarization of image 
     336        //Detect lines in image 
     337        //Go thru every line detected and check its gradient is less than SLOPEGRADIENT 
     338        // 
     339        //****************EXPLANATION************************************************** 
     340         
    277341        System.loadLibrary(Core.NATIVE_LIBRARY_NAME); 
    278342        Boolean isSheetMusic = null; 
     
    281345            //Variables 
    282346            int horizontalLineCount =0; 
     347             
    283348            Mat edgesDetected = new Mat(); 
    284349            Mat edgesDetectedRGB = new Mat(); 
     
    286351            Mat edgesDetectedRGBProb; 
    287352            ArrayList<StartAndEndPoint> pointArrayList = new ArrayList<StartAndEndPoint>(); 
    288  
    289             //****************EXPLANATION************************************************** 
    290             // 
    291             //Load an image in greyscale 
    292             //Additional matrix to hold results of line detection 
    293             //Inversed Binarization of image 
    294             //Detect lines in image 
    295             //Go thru every line detected and check its gradient is less than SLOPEGRADIENT 
    296             // 
    297             //****************EXPLANATION************************************************** 
    298  
    299353            Mat original = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE); 
     354             
     355            Mat binarized = original.clone(); 
     356            int blockSize = binarized.height()/3; 
     357            while (!(blockSize % 2 == 1 && blockSize > 1)) { 
     358                blockSize++; 
     359            } 
     360            System.out.println("Width: " + binarized.width() + " Height: " + binarized.height()); 
     361            //************************ 
     362            //Argument Setup 
     363            //************************ 
     364            double divisor; 
     365            switch (borderIgnoreAmount){ 
     366                case 5: 
     367                    divisor = 40; 
     368                    break; 
     369                case 10: 
     370                    divisor = 20; 
     371                    break; 
     372                case 20: 
     373                    divisor = 10; 
     374                    break; 
     375                case 40: 
     376                    divisor = 5; 
     377                    break; 
     378                case -1: 
     379                    divisor = -1; 
     380                    break; 
     381                default: divisor = -1; 
     382            } 
     383            if(divisor != -1 ) { 
     384                Mat mid = new Mat(); 
     385                Imgproc.adaptiveThreshold(original, mid,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, blockSize, THRESHOLD_C); 
     386                //Remove borders from Mat 
     387                //Get width and 
     388                double maxX = mid.size().width; 
     389                double maxY = mid.size().height; 
     390                Point cp1 = new Point(maxX / divisor, maxY / divisor); 
     391                Point cp2 = new Point(maxX - cp1.x, maxY - cp1.y); 
     392                Rect rectCrop = new Rect(cp1, cp2); 
     393                binarized = mid.submat(rectCrop); 
     394            } 
     395            else{Imgproc.adaptiveThreshold(original, binarized,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, blockSize, THRESHOLD_C);} 
     396            System.out.println("Width: " + binarized.width() + " Height: " + binarized.height());  
     397            edgesDetected = binarized.clone(); 
     398 
    300399            Mat linesP = new Mat(); //will hold the results of the detection 
    301             Imgproc.adaptiveThreshold(original, edgesDetected,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV,15, THRESHOLD_C); 
    302400            double minLineLength = edgesDetected.size().width/8; 
    303401            Imgproc.HoughLinesP(edgesDetected, linesP, 1, Math.PI / 720, HOUGHLINEP_THRESHOLD, minLineLength, MAXLINEGAP); 
     
    320418            } 
    321419            else if (isSheetMusic == false){ 
     420                System.out.println("TEST"); 
    322421                returnVariables = Classifier_ClusterDetection(pointArrayList); 
    323422            } 
     
    328427        return returnVariables; 
    329428    } 
    330     private static Pair Algorithm_MorphologyOLD2(String filename){ 
    331  
     429    private static Pair Algorithm_Morphology(String filename, int borderIgnoreAmount){ 
    332430        System.loadLibrary(Core.NATIVE_LIBRARY_NAME); 
    333         Boolean isSheetMusic = null; 
    334431        Pair returnVariables = new Pair(); 
    335432        int areaCounter = 0; 
    336         try{ 
    337             Mat edgesDetectedRGB = new Mat(); 
    338             Mat original = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE); 
    339  
    340             System.out.println("Width: " + original.width() + " Height: " + original.height()); 
    341  
    342             ArrayList<MatOfPoint> contours = new ArrayList<MatOfPoint>(); 
    343             Mat hierarchy = new Mat(); 
    344  
    345             //Thresholds 
    346             Imgproc.adaptiveThreshold(original, original,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
    347             Mat processed = original.clone(); 
    348             //Morphological Processing 
    349             Mat kernelErode = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,1)); 
    350             Imgproc.erode(processed,processed,kernelErode); 
    351  
    352             Mat kernelDilate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(20,3)); 
    353             Imgproc.dilate(processed,processed,kernelDilate); 
    354  
    355             Mat kernelOpening = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(4,4)); 
    356             Imgproc.morphologyEx(processed, processed, Imgproc.MORPH_CLOSE, kernelOpening); 
    357  
    358             Mat kernelErode02 = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(8,8)); 
    359             Imgproc.erode(processed,processed,kernelErode02); 
    360  
    361             //Detect contours 
    362             Imgproc.findContours(processed, contours, hierarchy, Imgproc.RETR_TREE, Imgproc.CHAIN_APPROX_SIMPLE); 
    363  
    364             //Record areas 
    365             for (int i = 0; i < contours.size(); i++) { 
    366                 double area = Imgproc.contourArea(contours.get(i)); 
    367                 System.out.println("AREA: " + area); 
    368                 //Check if area detected meets threshold 
    369                 if(area > THRESHOLD_AREA_SIZE) { 
    370                     areaCounter++; 
    371  
    372                 } 
    373             } 
    374             System.out.println("areacount = " + areaCounter); 
    375  
    376             //Calculates if sheet music or not 
    377             if(areaCounter >= THRESHOLD_AREA_COUNT){ 
    378                 isSheetMusic = true; 
    379                 returnVariables.setBoolean(isSheetMusic); 
    380                 returnVariables.setInteger(areaCounter); 
    381             } 
    382         } 
    383         catch(Exception e){ 
    384             System.err.println(e); 
    385         } 
    386         return returnVariables; 
    387     } 
    388     private static Pair Algorithm_MorphologyOLD(String filename){ 
    389  
    390         System.loadLibrary(Core.NATIVE_LIBRARY_NAME); 
    391         Boolean isSheetMusic = null; 
    392         Pair returnVariables = new Pair(); 
    393         int FILLED = -1; 
    394         try{ 
    395             Mat original1 = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE); 
    396             System.out.println("Width: " + original1.width() + " Height: " + original1.height()); 
    397             Mat original = original1.clone(); 
    398             Imgproc.adaptiveThreshold(original1, original,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
    399             Mat test = original.clone(); 
    400             //************************************ 
    401             //Large Object Removal 
    402             //************************************ 
    403             Mat srcLOR = original.clone(); 
    404             Mat maskLOR = new Mat(); 
    405             Mat dstLOR = new Mat(); 
    406  
    407             //denoize 
    408             Mat denoize = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(5,5)); 
    409             Imgproc.morphologyEx(srcLOR,maskLOR, Imgproc.MORPH_OPEN, denoize); 
    410  
    411             //close up gaps 
    412             Mat gapCloser = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(5,5)); 
    413             Imgproc.morphologyEx(maskLOR,maskLOR,Imgproc.MORPH_CLOSE, gapCloser); 
    414  
    415             //Isolate large items 
    416             Mat isolateLarge = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(8, 8)); 
    417             Imgproc.morphologyEx(maskLOR,maskLOR,Imgproc.MORPH_OPEN, isolateLarge); 
    418  
    419             //Remove large items from image 
    420             Core.bitwise_not(maskLOR,maskLOR); 
    421             srcLOR.copyTo(dstLOR, maskLOR); 
    422  
    423             //**************************************** 
    424             //Small object removal (SOR) 
    425             //**************************************** 
    426  
    427             Mat srcSOR = dstLOR.clone(); 
    428             Mat maskSOR = new Mat(); 
    429             Mat dstSOR = new Mat(); 
    430  
    431             Mat startSOR =Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(7,7)); 
    432             Imgproc.morphologyEx(srcSOR,maskSOR, Imgproc.MORPH_OPEN, startSOR); 
    433  
    434             Mat highlightSmall = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(7,7)); 
    435             Imgproc.dilate(maskSOR, maskSOR, highlightSmall); 
    436  
    437  
    438 /*              Mat isolateSmall =Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,10)); 
    439                 Imgproc.morphologyEx(maskSOR,maskSOR,Imgproc.MORPH_CLOSE, isolateSmall); 
    440                 imageViewer("13 isolate small - mask", maskSOR); 
    441 */ 
    442  
    443             //Remove small items from image 
    444             Core.bitwise_not(maskSOR, maskSOR); 
    445             srcSOR.copyTo(dstSOR, maskSOR); 
    446  
    447  
    448             //**************************************** 
    449             //start staff line detection 
    450             //**************************************** 
    451  
    452             Mat kernelErode = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(15,2)); //10,2 
    453             Imgproc.erode(dstSOR,test,kernelErode); 
    454  
    455  
    456             Mat kernelDilate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //20,3 
    457             Imgproc.dilate(test,test,kernelDilate); 
    458  
    459  
    460             Mat kernelClose = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //4,4 
    461             Imgproc.morphologyEx(test, test, Imgproc.MORPH_CLOSE, kernelClose); 
    462  
    463  
    464  
    465             Mat kernelErode02 = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //10,1 
    466             Imgproc.erode(test,test,kernelErode02); 
    467  
    468  
    469             //******************************************************************************** 
    470             //DETECT OUTLINE AND FIND AREA OF THESE LINES. 
    471             //******************************************************************************** 
    472             ArrayList<MatOfPoint> contours = new ArrayList<MatOfPoint>(); 
    473             ArrayList<MatOfPoint> largeContours = new ArrayList<MatOfPoint>(); 
    474             ArrayList<MatOfPoint> postContours = new ArrayList<MatOfPoint>(); 
    475             Mat hierarchy = new Mat(); 
    476  
    477             //PARAMETERS: input image, output array of arrays, output array, contour retrieval mode, contour approximation method. 
    478             //(contours)  output array of arrays: Detected contours. Each contour is stored as a vector of points 
    479             //(hierarchy) output array:           Optional output vector, containing information about the image topology. 
    480             //https://docs.opencv.org/3.3.1/d3/dc0/group__imgproc__shape.html#ga17ed9f5d79ae97bd4c7cf18403e1689a 
    481  
    482             Imgproc.findContours(test, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE); 
    483  
    484             System.out.println(contours.size()); 
    485             //Draw contours and record areas 
    486             Mat allContoursFound = Mat.zeros(test.size(), CvType.CV_8UC3); 
    487             Mat largeContoursFound = allContoursFound.clone() ; 
    488             Mat postContoursFound = allContoursFound.clone(); 
    489             int areaCounter = 0; 
    490  
    491             //Have created a preprocess to remove large objects. 
    492             //Need to now finalized Classifier, re try area detection. 
    493             //Paths to take - rectangle boxes around detected contours over threshold (area or perimeter) 
    494             //Just use area and periemter to determine if sheet music 
    495             //Discuss with david before weekend perhaps? 
    496  
    497             Imgproc.drawContours(allContoursFound, contours, -1, new Scalar(0, 255, 0), 1); //USES LINE_8 
    498             for (int i = 0; i < contours.size(); i++) { 
    499                 double area = Imgproc.contourArea(contours.get(i)); 
    500                 if(area > 100) { 
    501                     //System.out.println("AREA: " + area); 
    502                     Imgproc.drawContours(largeContoursFound, contours, i, new Scalar(255, 0, 0), FILLED); 
    503                     //create list of large coutours found 
    504                     largeContours.add(contours.get(i)); 
    505                 } 
    506             } 
    507  
    508             //***************************************************************** 
    509             //Circles and centres on processed images 
    510             //***************************************************************** 
    511  
    512             //Init arrays 
    513             Mat circleOutput = allContoursFound.clone(); 
    514             MatOfPoint2f[] contoursPoly  = new MatOfPoint2f[largeContours.size()]; 
    515             Point[] centers = new Point[largeContours.size()]; 
    516             float[][] radius = new float[largeContours.size()][1]; 
    517  
    518             //Fill arrays 
    519             for (int i = 0; i < largeContours.size(); i++) { 
    520                 contoursPoly[i] = new MatOfPoint2f(); 
    521                 Imgproc.approxPolyDP(new MatOfPoint2f(largeContours.get(i).toArray()), contoursPoly[i], 1, true); 
    522                 centers[i] = new Point(); 
    523                 Imgproc.minEnclosingCircle(contoursPoly[i], centers[i], radius[i]); 
    524  
    525             } 
    526             //Draw circle for each large contour 
    527             for (int i = 0; i < largeContours.size(); i++) { 
    528                 Imgproc.circle(circleOutput, centers[i], (int) radius[i][0],new Scalar(255, 0, 0), 1); 
    529             } 
    530  
    531  
    532             //******************************************************************************** 
    533             //Centroids - Everything must be to scale 
    534             //******************************************************************************** 
    535  
    536             ArrayList<Moments> mu = new ArrayList<Moments>(largeContours.size()); 
    537             Mat centreOutput = Mat.zeros(largeContoursFound.size(), CvType.CV_8UC3); 
    538             for (int i = 0; i < largeContours.size(); i++) { 
    539                 mu.add(i, Imgproc.moments(largeContours.get(i), false)); 
    540                 Moments p = mu.get(i); 
    541                 int x = (int) (p.get_m10() / p.get_m00()); 
    542                 int y = (int) (p.get_m01() / p.get_m00()); 
    543                 Imgproc.circle(centreOutput, new Point(x, y), 4, new Scalar(255, 255, 255), 30); 
    544             } 
    545  
    546             //*********************************************** 
    547             //PostProcessing - Morphology Classifier 
    548             //  Use dilation to "Connect the dots" 
    549             //  Testing showed the centroids were clustered together 
    550             //  Then use area or perimeter as a classifier filter 
    551             //*********************************************** 
    552  
    553             Mat postDilate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(150,15)); 
    554             Imgproc.dilate(centreOutput,centreOutput,postDilate); 
    555  
    556             Mat postClose = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //4,4 
    557             Imgproc.morphologyEx(centreOutput, centreOutput, Imgproc.MORPH_CLOSE, postClose); 
    558  
    559             Mat postDenoize = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(100,100)); 
    560             Imgproc.morphologyEx(centreOutput,centreOutput, Imgproc.MORPH_OPEN, postDenoize); 
    561  
    562             //Find area 
    563             Mat centreOutputGrey = new Mat(); 
    564             Imgproc.cvtColor(centreOutput, centreOutputGrey, Imgproc.COLOR_RGB2GRAY); 
    565             Imgproc.findContours(centreOutputGrey, postContours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE); 
    566  
    567             for (int i = 0; i < postContours.size(); i++) { 
    568                 double area = Imgproc.contourArea(postContours.get(i)); 
    569                 if(area > THRESHOLD_AREA_SIZE) { 
    570                     //System.err.println("POST AREA: " + area); 
    571                     Imgproc.drawContours(postContoursFound, postContours, i, new Scalar(0, 255, 0), FILLED); 
    572                     areaCounter++; 
    573                 } 
    574             } 
    575             //Classifier Calculation 
    576             if(areaCounter >= THRESHOLD_AREA_COUNT){ 
    577                 returnVariables.setBoolean(true); 
    578                 returnVariables.setInteger(areaCounter); 
    579             } 
    580         } 
    581         catch(Exception e){ 
    582             System.err.println(e); 
    583         } 
    584         return returnVariables; 
    585     } 
    586     private static Pair Algorithm_Morphology(String filename){ 
    587         System.loadLibrary(Core.NATIVE_LIBRARY_NAME); 
    588         Pair returnVariables = new Pair(); 
    589         int areaCounter=0; 
    590433        Mat original = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE); 
    591         Mat binarizedOriginal = original.clone(); 
    592         Imgproc.adaptiveThreshold(original, binarizedOriginal,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
     434        Mat binarized = original.clone(); 
     435        int blockSize = binarized.height()/3;    
     436        while (!(blockSize % 2 == 1 && blockSize > 1)) { 
     437            blockSize++; 
     438        } 
     439        System.out.println("Width: " + binarized.width() + " Height: " + binarized.height()); 
     440        //************************ 
     441        //Argument Setup 
     442        //************************ 
     443        double divisor; 
     444        switch (borderIgnoreAmount){ 
     445            case 5: 
     446                divisor = 40; 
     447                break; 
     448            case 10: 
     449                divisor = 20; 
     450                break; 
     451            case 20: 
     452                divisor = 10; 
     453                break; 
     454            case 40: 
     455                divisor = 5; 
     456                break; 
     457            case -1: 
     458                divisor = -1; 
     459                break; 
     460            default: divisor = -1; 
     461        } 
     462        if(divisor != -1 ) { 
     463            Mat mid = new Mat(); 
     464            Imgproc.adaptiveThreshold(original, mid,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, blockSize, THRESHOLD_C); 
     465            //Remove borders from Mat 
     466            //Get width and 
     467            double maxX = mid.size().width; 
     468            double maxY = mid.size().height; 
     469            Point cp1 = new Point(maxX / divisor, maxY / divisor); 
     470            Point cp2 = new Point(maxX - cp1.x, maxY - cp1.y); 
     471            Rect rectCrop = new Rect(cp1, cp2); 
     472            binarized = mid.submat(rectCrop); 
     473        } 
     474        else{Imgproc.adaptiveThreshold(original, binarized,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, blockSize, THRESHOLD_C);} 
     475        System.out.println("Width: " + binarized.width() + " Height: " + binarized.height()); 
    593476        try{ 
    594477            //************************************ 
    595478            //1. Large Object Remover 
    596479            //************************************ 
    597             Mat srcLOR = binarizedOriginal.clone(); 
     480            Mat srcLOR = binarized.clone(); 
    598481            Mat maskLOR = new Mat(); 
    599482            Mat dstLOR = new Mat(); 
     
    614497            srcLOR.copyTo(dstLOR, maskLOR); 
    615498 
    616             Mat base = binarizedOriginal.clone(); 
     499            Mat base = binarized.clone(); 
    617500            //*********************************** 
    618501            //3. Isolate straight lines 
     
    872755        } 
    873756    } 
     757 
     758    //****************** 
     759    //OLD FUNCTIONS 
     760    //****************** 
     761    private static Pair Algorithm_MorphologyOLD2(String filename){ 
     762 
     763        System.loadLibrary(Core.NATIVE_LIBRARY_NAME); 
     764        Boolean isSheetMusic = null; 
     765        Pair returnVariables = new Pair(); 
     766        int areaCounter = 0; 
     767        try{ 
     768            Mat edgesDetectedRGB = new Mat(); 
     769            Mat original = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE); 
     770 
     771            System.out.println("Width: " + original.width() + " Height: " + original.height()); 
     772 
     773            ArrayList<MatOfPoint> contours = new ArrayList<MatOfPoint>(); 
     774            Mat hierarchy = new Mat(); 
     775 
     776            //Thresholds 
     777            Imgproc.adaptiveThreshold(original, original,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
     778            Mat processed = original.clone(); 
     779            //Morphological Processing 
     780            Mat kernelErode = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,1)); 
     781            Imgproc.erode(processed,processed,kernelErode); 
     782 
     783            Mat kernelDilate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(20,3)); 
     784            Imgproc.dilate(processed,processed,kernelDilate); 
     785 
     786            Mat kernelOpening = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(4,4)); 
     787            Imgproc.morphologyEx(processed, processed, Imgproc.MORPH_CLOSE, kernelOpening); 
     788 
     789            Mat kernelErode02 = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(8,8)); 
     790            Imgproc.erode(processed,processed,kernelErode02); 
     791 
     792            //Detect contours 
     793            Imgproc.findContours(processed, contours, hierarchy, Imgproc.RETR_TREE, Imgproc.CHAIN_APPROX_SIMPLE); 
     794 
     795            //Record areas 
     796            for (int i = 0; i < contours.size(); i++) { 
     797                double area = Imgproc.contourArea(contours.get(i)); 
     798                System.out.println("AREA: " + area); 
     799                //Check if area detected meets threshold 
     800                if(area > THRESHOLD_AREA_SIZE) { 
     801                    areaCounter++; 
     802 
     803                } 
     804            } 
     805            System.out.println("areacount = " + areaCounter); 
     806 
     807            //Calculates if sheet music or not 
     808            if(areaCounter >= THRESHOLD_AREA_COUNT){ 
     809                isSheetMusic = true; 
     810                returnVariables.setBoolean(isSheetMusic); 
     811                returnVariables.setInteger(areaCounter); 
     812            } 
     813        } 
     814        catch(Exception e){ 
     815            System.err.println(e); 
     816        } 
     817        return returnVariables; 
     818    } 
     819    private static Pair Algorithm_MorphologyOLD(String filename){ 
     820 
     821        System.loadLibrary(Core.NATIVE_LIBRARY_NAME); 
     822        Boolean isSheetMusic = null; 
     823        Pair returnVariables = new Pair(); 
     824        int FILLED = -1; 
     825        try{ 
     826            Mat original1 = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE); 
     827            System.out.println("Width: " + original1.width() + " Height: " + original1.height()); 
     828            Mat original = original1.clone(); 
     829            Imgproc.adaptiveThreshold(original1, original,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
     830            Mat test = original.clone(); 
     831            //************************************ 
     832            //Large Object Removal 
     833            //************************************ 
     834            Mat srcLOR = original.clone(); 
     835            Mat maskLOR = new Mat(); 
     836            Mat dstLOR = new Mat(); 
     837 
     838            //denoize 
     839            Mat denoize = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(5,5)); 
     840            Imgproc.morphologyEx(srcLOR,maskLOR, Imgproc.MORPH_OPEN, denoize); 
     841 
     842            //close up gaps 
     843            Mat gapCloser = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(5,5)); 
     844            Imgproc.morphologyEx(maskLOR,maskLOR,Imgproc.MORPH_CLOSE, gapCloser); 
     845 
     846            //Isolate large items 
     847            Mat isolateLarge = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(8, 8)); 
     848            Imgproc.morphologyEx(maskLOR,maskLOR,Imgproc.MORPH_OPEN, isolateLarge); 
     849 
     850            //Remove large items from image 
     851            Core.bitwise_not(maskLOR,maskLOR); 
     852            srcLOR.copyTo(dstLOR, maskLOR); 
     853 
     854            //**************************************** 
     855            //Small object removal (SOR) 
     856            //**************************************** 
     857 
     858            Mat srcSOR = dstLOR.clone(); 
     859            Mat maskSOR = new Mat(); 
     860            Mat dstSOR = new Mat(); 
     861 
     862            Mat startSOR =Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(7,7)); 
     863            Imgproc.morphologyEx(srcSOR,maskSOR, Imgproc.MORPH_OPEN, startSOR); 
     864 
     865            Mat highlightSmall = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(7,7)); 
     866            Imgproc.dilate(maskSOR, maskSOR, highlightSmall); 
     867 
     868 
     869/*              Mat isolateSmall =Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,10)); 
     870                Imgproc.morphologyEx(maskSOR,maskSOR,Imgproc.MORPH_CLOSE, isolateSmall); 
     871                imageViewer("13 isolate small - mask", maskSOR); 
     872*/ 
     873 
     874            //Remove small items from image 
     875            Core.bitwise_not(maskSOR, maskSOR); 
     876            srcSOR.copyTo(dstSOR, maskSOR); 
     877 
     878 
     879            //**************************************** 
     880            //start staff line detection 
     881            //**************************************** 
     882 
     883            Mat kernelErode = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(15,2)); //10,2 
     884            Imgproc.erode(dstSOR,test,kernelErode); 
     885 
     886 
     887            Mat kernelDilate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //20,3 
     888            Imgproc.dilate(test,test,kernelDilate); 
     889 
     890 
     891            Mat kernelClose = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //4,4 
     892            Imgproc.morphologyEx(test, test, Imgproc.MORPH_CLOSE, kernelClose); 
     893 
     894 
     895 
     896            Mat kernelErode02 = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //10,1 
     897            Imgproc.erode(test,test,kernelErode02); 
     898 
     899 
     900            //******************************************************************************** 
     901            //DETECT OUTLINE AND FIND AREA OF THESE LINES. 
     902            //******************************************************************************** 
     903            ArrayList<MatOfPoint> contours = new ArrayList<MatOfPoint>(); 
     904            ArrayList<MatOfPoint> largeContours = new ArrayList<MatOfPoint>(); 
     905            ArrayList<MatOfPoint> postContours = new ArrayList<MatOfPoint>(); 
     906            Mat hierarchy = new Mat(); 
     907 
     908            //PARAMETERS: input image, output array of arrays, output array, contour retrieval mode, contour approximation method. 
     909            //(contours)  output array of arrays: Detected contours. Each contour is stored as a vector of points 
     910            //(hierarchy) output array:           Optional output vector, containing information about the image topology. 
     911            //https://docs.opencv.org/3.3.1/d3/dc0/group__imgproc__shape.html#ga17ed9f5d79ae97bd4c7cf18403e1689a 
     912 
     913            Imgproc.findContours(test, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE); 
     914 
     915            System.out.println(contours.size()); 
     916            //Draw contours and record areas 
     917            Mat allContoursFound = Mat.zeros(test.size(), CvType.CV_8UC3); 
     918            Mat largeContoursFound = allContoursFound.clone() ; 
     919            Mat postContoursFound = allContoursFound.clone(); 
     920            int areaCounter = 0; 
     921 
     922            //Have created a preprocess to remove large objects. 
     923            //Need to now finalized Classifier, re try area detection. 
     924            //Paths to take - rectangle boxes around detected contours over threshold (area or perimeter) 
     925            //Just use area and periemter to determine if sheet music 
     926            //Discuss with david before weekend perhaps? 
     927 
     928            Imgproc.drawContours(allContoursFound, contours, -1, new Scalar(0, 255, 0), 1); //USES LINE_8 
     929            for (int i = 0; i < contours.size(); i++) { 
     930                double area = Imgproc.contourArea(contours.get(i)); 
     931                if(area > 100) { 
     932                    //System.out.println("AREA: " + area); 
     933                    Imgproc.drawContours(largeContoursFound, contours, i, new Scalar(255, 0, 0), FILLED); 
     934                    //create list of large coutours found 
     935                    largeContours.add(contours.get(i)); 
     936                } 
     937            } 
     938 
     939            //***************************************************************** 
     940            //Circles and centres on processed images 
     941            //***************************************************************** 
     942 
     943            //Init arrays 
     944            Mat circleOutput = allContoursFound.clone(); 
     945            MatOfPoint2f[] contoursPoly  = new MatOfPoint2f[largeContours.size()]; 
     946            Point[] centers = new Point[largeContours.size()]; 
     947            float[][] radius = new float[largeContours.size()][1]; 
     948 
     949            //Fill arrays 
     950            for (int i = 0; i < largeContours.size(); i++) { 
     951                contoursPoly[i] = new MatOfPoint2f(); 
     952                Imgproc.approxPolyDP(new MatOfPoint2f(largeContours.get(i).toArray()), contoursPoly[i], 1, true); 
     953                centers[i] = new Point(); 
     954                Imgproc.minEnclosingCircle(contoursPoly[i], centers[i], radius[i]); 
     955 
     956            } 
     957            //Draw circle for each large contour 
     958            for (int i = 0; i < largeContours.size(); i++) { 
     959                Imgproc.circle(circleOutput, centers[i], (int) radius[i][0],new Scalar(255, 0, 0), 1); 
     960            } 
     961 
     962 
     963            //******************************************************************************** 
     964            //Centroids - Everything must be to scale 
     965            //******************************************************************************** 
     966 
     967            ArrayList<Moments> mu = new ArrayList<Moments>(largeContours.size()); 
     968            Mat centreOutput = Mat.zeros(largeContoursFound.size(), CvType.CV_8UC3); 
     969            for (int i = 0; i < largeContours.size(); i++) { 
     970                mu.add(i, Imgproc.moments(largeContours.get(i), false)); 
     971                Moments p = mu.get(i); 
     972                int x = (int) (p.get_m10() / p.get_m00()); 
     973                int y = (int) (p.get_m01() / p.get_m00()); 
     974                Imgproc.circle(centreOutput, new Point(x, y), 4, new Scalar(255, 255, 255), 30); 
     975            } 
     976 
     977            //*********************************************** 
     978            //PostProcessing - Morphology Classifier 
     979            //  Use dilation to "Connect the dots" 
     980            //  Testing showed the centroids were clustered together 
     981            //  Then use area or perimeter as a classifier filter 
     982            //*********************************************** 
     983 
     984            Mat postDilate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(150,15)); 
     985            Imgproc.dilate(centreOutput,centreOutput,postDilate); 
     986 
     987            Mat postClose = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //4,4 
     988            Imgproc.morphologyEx(centreOutput, centreOutput, Imgproc.MORPH_CLOSE, postClose); 
     989 
     990            Mat postDenoize = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(100,100)); 
     991            Imgproc.morphologyEx(centreOutput,centreOutput, Imgproc.MORPH_OPEN, postDenoize); 
     992 
     993            //Find area 
     994            Mat centreOutputGrey = new Mat(); 
     995            Imgproc.cvtColor(centreOutput, centreOutputGrey, Imgproc.COLOR_RGB2GRAY); 
     996            Imgproc.findContours(centreOutputGrey, postContours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE); 
     997 
     998            for (int i = 0; i < postContours.size(); i++) { 
     999                double area = Imgproc.contourArea(postContours.get(i)); 
     1000                if(area > THRESHOLD_AREA_SIZE) { 
     1001                    //System.err.println("POST AREA: " + area); 
     1002                    Imgproc.drawContours(postContoursFound, postContours, i, new Scalar(0, 255, 0), FILLED); 
     1003                    areaCounter++; 
     1004                } 
     1005            } 
     1006            //Classifier Calculation 
     1007            if(areaCounter >= THRESHOLD_AREA_COUNT){ 
     1008                returnVariables.setBoolean(true); 
     1009                returnVariables.setInteger(areaCounter); 
     1010            } 
     1011        } 
     1012        catch(Exception e){ 
     1013            System.err.println(e); 
     1014        } 
     1015        return returnVariables; 
     1016    } 
    8741017} 
  • other-projects/is-sheet-music-encore/trunk/image-identification-terminal/runClassifer.sh

    r33458 r33589  
    11#!/bin/bash 
     2#https://www.cyberciti.biz/faq/linux-unix-shell-check-if-directory-empty/ 
    23 
    3 if [ $# != 4 ] ; then  
    4   echo "Usage: ./testClassifier.sh folder/file classifier_type output_filename  type(-a:all -test:100 -single:1)" 1>&2 
     4if [ $# -lt 4 ] ; then  
     5  echo "Usage: ./testClassifier.sh  <folder/file> <classifier_type> <output_filename> <amount>" 1>&2 
     6  echo "<amount> options: -a (all) -test (100) -single (1)" 
    57  exit 1 
    68fi 
    7  
     9if [ $# -eq 5 ] ; then 
     10    borderIgnore=$5 
     11fi 
    812source=$1 
    913classifier_type=$2 
    1014output=$3 
     15 
     16 
     17 
    1118i=0 
    1219j=0 
     
    6875        javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar -Xlint javaClassifierComparison.java; 
    6976        #Runs javaImageClassifier on 10 images of each 
    70         for file in $source/SheetMusic/*.png; do 
    71             if [ $i -lt 100 ] ; then 
    72                 echo $file 
    73                 echo $output 
    74                 echo $i 
    75                 echo "" 
    76                 java -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar:. -Djava.library.path=/Scratch/cpb16/opencv-3.4.2/build/lib/  javaClassifierComparison $file $classifier_type $output 
    77                 i=$[$i+1]        
    78             fi 
    79         done 
    80         for file in $source/NotSheetMusic/*.png; do 
    81             if [ $j -lt 100 ] ; then 
    82                 echo $file 
    83                 echo $output 
    84                 echo $j 
    85                 echo "" 
    86                 java -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar:. -Djava.library.path=/Scratch/cpb16/opencv-3.4.2/build/lib/  javaClassifierComparison $file $classifier_type $output 
    87                 j=$[$j+1]        
    88             fi 
    89         done 
     77        if [ "$(ls -A $source/SheetMusic)" ]; then 
     78            #Not Empty 
     79            for file in $source/SheetMusic/*.png; do 
     80                if [ $i -lt 10 ] ; then 
     81                    echo $file 
     82                    echo $output 
     83                    echo $i 
     84                    echo "" 
     85                    java -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar:. -Djava.library.path=/Scratch/cpb16/opencv-3.4.2/build/lib/  javaClassifierComparison $file $classifier_type $output 
     86                    i=$[$i+1]        
     87                fi 
     88            done 
     89        else 
     90            echo "$source/SheetMusic is Empty" 
     91        fi 
     92         
     93        if [ "$(ls -A $source/NotSheetMusic)" ]; then 
     94            #Not Empty 
     95            for file in $source/NotSheetMusic/*.png; do 
     96                if [ $j -lt 10 ] ; then 
     97                    echo $file 
     98                    echo $output 
     99                    echo $j 
     100                    echo "" 
     101                    java -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar:. -Djava.library.path=/Scratch/cpb16/opencv-3.4.2/build/lib/  javaClassifierComparison $file $classifier_type $output 
     102                    j=$[$j+1]        
     103                fi 
     104            done 
     105        else 
     106            echo "$source/NotSheetMusic is Empty" 
     107        fi 
    90108        ;; 
    91109#________________________________________________________________________________________________________________________________________________________________________________________ 
     
    107125        echo $output 
    108126        echo $classifier_type 
    109         java -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar:. -Djava.library.path=/Scratch/cpb16/opencv-3.4.2/build/lib/  javaClassifierComparison $source $classifier_type $output 
     127        echo $borderIgnore 
     128        java -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar:. -Djava.library.path=/Scratch/cpb16/opencv-3.4.2/build/lib/  javaClassifierComparison $source $classifier_type $output $borderIgnore 
    110129        ;;   
    111130esac