Changeset 33455

Show
Ignore:
Timestamp:
04.09.2019 14:45:52 (2 weeks ago)
Author:
cpb16
Message:

Started implementing Davids suggested morphology sequence, codeversion9

Location:
other-projects/is-sheet-music-encore/trunk
Files:
6 modified

Legend:

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

    r33439 r33455  
    3535#Classifier Scripts [HIGHRES BY DEFUALT] 
    3636#**************************************************************************************************** 
     37if [ $type == "morph" ] ; then 
     38    if [ $# != 2 ] ; then 
     39        echo "Usage:./EndToEndSystem cluster <ResultSubDirectory>" 
     40        exit 1 
     41    fi 
     42    location=$2 
     43    #Compile 
     44    echo "Compiling java programs..." 
     45    cd image-identification-terminal 
     46    javac javaAccuracyCalculator.java 
     47    javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java; 
     48    #Classifiers 
     49    echo "Successfuly Compiled, running classifer now..." 
     50    ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU morphology log-EndToEnd/$location/log-morph-MU.txt -allNew 
     51    ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/BK morphology log-EndToEnd/$location/log-morph-BK.txt -allNew 
     52    ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MP morphology log-EndToEnd/$location/log-morph-MP.txt -allNew 
     53    ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/SE morphology log-EndToEnd/$location/log-morph-SE.txt -allNew 
     54    #Results 
     55    echo "Successfuly Classified, writing results now..." 
     56    mkdir log-EndToEnd/$location/ 
     57    echo $'\n***********************************************\n' >> log-EndToEnd/$location/results.txt 
     58    date >> log-EndToEnd/$location/results.txt 
     59    echo >> log-EndToEnd/$location/results.txt 
     60    #echo "" >> log-EndToEnd/$location/results.txt 
     61    cat configClassifierComparison.properties >> log-EndToEnd/$location/results.txt 
     62    java javaAccuracyCalculator log-EndToEnd/$location/log-morph-MU.txt morph-MU log-EndToEnd/$location/results.txt 
     63    java javaAccuracyCalculator log-EndToEnd/$location/log-morph-BK.txt morph-BK log-EndToEnd/$location/results.txt 
     64    java javaAccuracyCalculator log-EndToEnd/$location/log-morph-MP.txt morph-MP log-EndToEnd/$location/results.txt 
     65    java javaAccuracyCalculator log-EndToEnd/$location/log-morph-SE.txt morph-SE log-EndToEnd/$location/results.txt 
     66    .././calculateCorpusAccuracy.sh 
     67    less log-EndToEnd/$location/results.txt  
     68    exit 1 
     69fi 
     70 
    3771if [ $type == "cluster" ] ; then 
    3872     
  • other-projects/is-sheet-music-encore/trunk/image-identification-dev-02/.idea/workspace.xml

    r33449 r33455  
    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="-53"> 
    18               <caret line="746" column="42" selection-start-line="746" selection-start-column="42" selection-end-line="746" selection-end-column="42" /> 
     17            <state relative-caret-position="677"> 
     18              <caret line="779" column="12" selection-start-line="779" selection-start-column="12" selection-end-line="779" selection-end-column="12" /> 
    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="33"> 
    43               <caret line="143" column="32" selection-start-line="143" selection-start-column="32" selection-end-line="143" selection-end-column="32" /> 
     42            <state relative-caret-position="144"> 
     43              <caret line="1217" column="16" selection-start-line="1217" selection-start-column="16" selection-end-line="1217" selection-end-column="16" /> 
    4444              <folding> 
    4545                <element signature="imports" expanded="true" /> 
    4646                <element signature="class#Pair#0;class#MainMorph#0" /> 
    4747                <element signature="method#imageViewer#0;class#MainMorph#0" /> 
    48                 <element signature="e#11259#13729#1" /> 
    49                 <element signature="e#13814#15817#1" /> 
    50                 <element signature="e#15886#18509#1" /> 
    51                 <element signature="e#18593#24264#1" /> 
    52                 <element signature="e#24349#28326#1" /> 
    53                 <element signature="e#28394#29572#1" /> 
    54                 <element signature="e#29641#33604#1" /> 
    55                 <element signature="e#33714#45393#1" /> 
     48                <element signature="e#13990#16460#1" /> 
     49                <element signature="e#16545#18548#1" /> 
     50                <element signature="e#18617#21240#1" /> 
     51                <element signature="e#21324#26995#1" /> 
     52                <element signature="e#27080#31057#1" /> 
     53                <element signature="e#31125#32303#1" /> 
     54                <element signature="e#32372#36335#1" /> 
     55                <element signature="e#36445#48148#1" /> 
    5656                <element signature="e#42969#43036#0" /> 
    57                 <element signature="e#45494#55203#1" /> 
     57                <element signature="e#48242#59125#1" /> 
    5858              </folding> 
    5959            </state> 
     
    6464        <entry file="file://$PROJECT_DIR$/../image-identification-terminal/javaClassifierComparison.java"> 
    6565          <provider selected="true" editor-type-id="text-editor"> 
    66             <state relative-caret-position="338"> 
     66            <state relative-caret-position="1539"> 
    6767              <caret line="135" column="4" selection-start-line="135" selection-start-column="4" selection-end-line="160" selection-end-column="5" /> 
    6868              <folding> 
     
    107107        <option value="$PROJECT_DIR$/../image-identification-terminal/javaImageClassifier.java" /> 
    108108        <option value="$PROJECT_DIR$/../image-identification-terminal/javaClassifierComparison" /> 
     109        <option value="$PROJECT_DIR$/../image-identification-terminal/javaClassifierComparison.java" /> 
    109110        <option value="$PROJECT_DIR$/image-identification-development/src/Main.java" /> 
    110         <option value="$PROJECT_DIR$/../image-identification-terminal/javaClassifierComparison.java" /> 
    111111        <option value="$PROJECT_DIR$/image-identification-development/src/MainMorph.java" /> 
    112112      </list> 
     
    189189      <window_info anchor="bottom" id="Message" order="0" /> 
    190190      <window_info anchor="bottom" id="Find" order="1" weight="0.32962137" /> 
    191       <window_info anchor="bottom" id="Run" order="2" weight="0.27616927" /> 
     191      <window_info anchor="bottom" id="Run" order="2" weight="0.27951002" /> 
    192192      <window_info anchor="bottom" id="Debug" order="3" weight="0.3997773" /> 
    193193      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> 
     
    234234      </provider> 
    235235    </entry> 
    236     <entry file="file://$PROJECT_DIR$/image-identification-development/src/Main.java"> 
    237       <provider selected="true" editor-type-id="text-editor"> 
    238         <state relative-caret-position="-53"> 
    239           <caret line="746" column="42" selection-start-line="746" selection-start-column="42" selection-end-line="746" selection-end-column="42" /> 
    240           <folding> 
    241             <element signature="imports" expanded="true" /> 
    242             <element signature="class#StartAndEndPoint#0;class#Main#0" /> 
    243             <element signature="method#removeDuplicates#0;class#Main#0" /> 
    244             <element signature="method#StandardDeviation#0;class#Main#0" /> 
    245             <element signature="method#VarianceCalc#0;class#Main#0" /> 
    246             <element signature="method#lineComparison#0;class#Main#0" /> 
    247             <element signature="method#ClusterCheck#0;class#Main#0" /> 
    248             <element signature="method#toBufferedImage#0;class#Main#0" /> 
    249             <element signature="method#ClassifierPixelCount#0;class#Main#0" /> 
    250             <element signature="method#ClassifierLineCount#0;class#Main#0" /> 
    251             <element signature="method#ClassifierLineClusterOLD#0;class#Main#0" /> 
    252             <element signature="method#ClassifierLineCluster#0;class#Main#0" /> 
    253             <element signature="method#ClassifierLineClusterPt#0;class#Main#0" /> 
    254             <element signature="method#LineCountOrCluster#0;class#Main#0" /> 
    255           </folding> 
    256         </state> 
    257       </provider> 
    258     </entry> 
    259236    <entry file="file://$PROJECT_DIR$/../image-identification-terminal/javaClassifierComparison.java"> 
    260237      <provider selected="true" editor-type-id="text-editor"> 
    261         <state relative-caret-position="338"> 
     238        <state relative-caret-position="1539"> 
    262239          <caret line="135" column="4" selection-start-line="135" selection-start-column="4" selection-end-line="160" selection-end-column="5" /> 
    263240          <folding> 
     
    280257      </provider> 
    281258    </entry> 
     259    <entry file="file://$PROJECT_DIR$/image-identification-development/src/Main.java"> 
     260      <provider selected="true" editor-type-id="text-editor"> 
     261        <state relative-caret-position="677"> 
     262          <caret line="779" column="12" selection-start-line="779" selection-start-column="12" selection-end-line="779" selection-end-column="12" /> 
     263          <folding> 
     264            <element signature="imports" expanded="true" /> 
     265            <element signature="class#StartAndEndPoint#0;class#Main#0" /> 
     266            <element signature="method#removeDuplicates#0;class#Main#0" /> 
     267            <element signature="method#StandardDeviation#0;class#Main#0" /> 
     268            <element signature="method#VarianceCalc#0;class#Main#0" /> 
     269            <element signature="method#lineComparison#0;class#Main#0" /> 
     270            <element signature="method#ClusterCheck#0;class#Main#0" /> 
     271            <element signature="method#toBufferedImage#0;class#Main#0" /> 
     272            <element signature="method#ClassifierPixelCount#0;class#Main#0" /> 
     273            <element signature="method#ClassifierLineCount#0;class#Main#0" /> 
     274            <element signature="method#ClassifierLineClusterOLD#0;class#Main#0" /> 
     275            <element signature="method#ClassifierLineCluster#0;class#Main#0" /> 
     276            <element signature="method#ClassifierLineClusterPt#0;class#Main#0" /> 
     277            <element signature="method#LineCountOrCluster#0;class#Main#0" /> 
     278          </folding> 
     279        </state> 
     280      </provider> 
     281    </entry> 
    282282    <entry file="file://$PROJECT_DIR$/image-identification-development/src/MainMorph.java"> 
    283283      <provider selected="true" editor-type-id="text-editor"> 
    284         <state relative-caret-position="33"> 
    285           <caret line="143" column="32" selection-start-line="143" selection-start-column="32" selection-end-line="143" selection-end-column="32" /> 
     284        <state relative-caret-position="144"> 
     285          <caret line="1217" column="16" selection-start-line="1217" selection-start-column="16" selection-end-line="1217" selection-end-column="16" /> 
    286286          <folding> 
    287287            <element signature="imports" expanded="true" /> 
    288288            <element signature="class#Pair#0;class#MainMorph#0" /> 
    289289            <element signature="method#imageViewer#0;class#MainMorph#0" /> 
    290             <element signature="e#11259#13729#1" /> 
    291             <element signature="e#13814#15817#1" /> 
    292             <element signature="e#15886#18509#1" /> 
    293             <element signature="e#18593#24264#1" /> 
    294             <element signature="e#24349#28326#1" /> 
    295             <element signature="e#28394#29572#1" /> 
    296             <element signature="e#29641#33604#1" /> 
    297             <element signature="e#33714#45393#1" /> 
     290            <element signature="e#13990#16460#1" /> 
     291            <element signature="e#16545#18548#1" /> 
     292            <element signature="e#18617#21240#1" /> 
     293            <element signature="e#21324#26995#1" /> 
     294            <element signature="e#27080#31057#1" /> 
     295            <element signature="e#31125#32303#1" /> 
     296            <element signature="e#32372#36335#1" /> 
     297            <element signature="e#36445#48148#1" /> 
    298298            <element signature="e#42969#43036#0" /> 
    299             <element signature="e#45494#55203#1" /> 
     299            <element signature="e#48242#59125#1" /> 
    300300          </folding> 
    301301        </state> 
  • other-projects/is-sheet-music-encore/trunk/image-identification-dev-02/image-identification-development/src/Main.java

    r33449 r33455  
    768768            //String default_file =hiresDirectory+"BK/NotSheetMusic/aeu.ark+=13960=t2q53nq6w-6.png"; 
    769769 
    770             String default_file = "/Scratch/cpb16/is-sheet-music-encore/image-identification-terminal/TestImages/test-coo.31924062612282-9.png"; 
     770            //String default_file = "/Scratch/cpb16/is-sheet-music-encore/image-identification-terminal/TestImages/test-coo.31924062612282-9.png"; 
    771771            //String default_file = "/Scratch/cpb16/is-sheet-music-encore/image-identification-terminal/TestImages/mdp.39015080937769-1.png"; 
    772772            //String default_file = "/Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU/SheetMusic/coo.31924062612282-9.png"; 
     
    778778            //String default_file = "TestImages/SheetMusic01.png"; 
    779779            //String default_file = "TestImages/SheetMusic02.png"; 
    780             //String default_file = "TestImages/vLine.png"; 
     780            String default_file = "TestImages/vLine.png"; 
    781781            String filename = ((args.length > 0) ? args[0] : default_file); 
    782782            File file = new File(filename); 
  • other-projects/is-sheet-music-encore/trunk/image-identification-dev-02/image-identification-development/src/MainMorph.java

    r33449 r33455  
    6969import static org.opencv.highgui.HighGui.createJFrame; 
    7070import static org.opencv.highgui.HighGui.imshow; 
     71import static org.opencv.imgcodecs.Imgcodecs.imread; 
    7172import static org.opencv.imgcodecs.Imgcodecs.imwrite; 
    7273 
     
    205206            //!!!!!!!!!!!!!!!!!!!!!!!!!!!NOTNOT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    206207            //coo.31924062612282-9.png 8   lines 
    207             //String default_file = directory+"NotSheetMusic/coo.31924062612282-9.png"; 
    208             //String default_file = directory+"NotSheetMusic/mdp.39015097852365-2.png"; 
    209208            //String default_file =testDirectory+"TestImages/NotNot/mdp.39015080972303-3.png"; //WHY GREY? DUE TO IMAGE LARGE, ZOOM IN 
    210209            //String default_file =hiresDirectory+"BK/NotSheetMusic/aeu.ark+=13960=t2q53nq6w-6.png"; 
     
    214213            //String default_file =hiresDirectory+"MU/SheetMusic/bc.ark+=13960=t2j72dt1p-10.png"; 
    215214            //String default_file =hiresDirectory+"MU/SheetMusic/bc.ark+=13960=t2j72dt1p-7.png"; 
    216             String default_file =hiresDirectory+"MU/SheetMusic/coo.31924062612282-9.png"; 
     215            //String default_file =hiresDirectory+"MU/SheetMusic/coo.31924062612282-9.png"; 
    217216            //String default_file =hiresDirectory+"MU/NotSheetMusic/mdp.39015096363935-1.png"; 
    218217            //String default_file =hiresDirectory+"MU/SheetMusic/coo.31924062612282-9.png"; 
    219218            //String default_file = "/Scratch/cpb16/is-sheet-music-encore/image-identification-terminal/TestImages/hi-res-test-coo.31924062612282-9.png"; 
     219 
     220            //String default_file = hiresDirectory+"/BK/NotSheetMusic/aeu.ark+=13960=t2s47k537-4.png"; //centre example 
     221            //String default_file = hiresDirectory+"/BK/NotSheetMusic/aeu.ark+=13960=t3tt4xf2t-2.png"; //cross 
    220222            //TestNew images used 
    221  
    222             //String default_file = hiresDirectory+"/MU/SheetMusic/aeu.ark+=13960=t93787r1w-10.png"; 
    223             //String default_file = "hiresDirectory+"/MU/SheetMusic/bc.ark+=13960=t2j72dt1p-10.png"; 
    224             //String default_file = hiresDirectory+"/MU/SheetMusic/bc.ark+=13960=t2j72dt1p-7.png";  //Handwritten 
    225             //String default_file = hiresDirectory+"/MU/SheetMusic/bc.ark+=13960=t2j72dt1p-8.png";  //Handwritten 
    226             //String default_file = hiresDirectory+"/MU/SheetMusic/bc.ark+=13960=t2j72dt1p-9.png";    //Handwritten 
    227             //String default_file = hiresDirectory+"/MU/SheetMusic/coo.31924062612282-9.png"; 
    228             //String default_file = hiresDirectory+"/MU/SheetMusic/dul1.ark+=13960=t2x41569k-10.png"; 
     223            //String default_file = hiresDirectory+"/MU/SheetMusic/aeu.ark+=13960=t93787r1w-10.png";    //Bleed 
     224            //String default_file = hiresDirectory+"/MU/SheetMusic/bc.ark+=13960=t2j72dt1p-10.png";     //Handwritten 
     225            //String default_file = hiresDirectory+"/MU/SheetMusic/bc.ark+=13960=t2j72dt1p-7.png";      //Handwritten 3072 4176 
     226            //String default_file = hiresDirectory+"/MU/SheetMusic/bc.ark+=13960=t2j72dt1p-8.png";      //Handwritten 
     227            //String default_file = hiresDirectory+"/MU/SheetMusic/bc.ark+=13960=t2j72dt1p-9.png";      //Handwritten 
     228            String default_file = hiresDirectory+"/MU/SheetMusic/coo.31924062612282-9.png";           //Snippet 
     229            //String default_file = hiresDirectory+"/MU/SheetMusic/dul1.ark+=13960=t2x41569k-10.png";   //Generated 
    229230            //String default_file = hiresDirectory+"/MU/SheetMusic/dul1.ark+=13960=t2x41569k-7.png"; 
    230231            //String default_file = hiresDirectory+"/MU/SheetMusic/dul1.ark+=13960=t2x41569k-8.png"; 
    231232            //String default_file = hiresDirectory+"/MU/SheetMusic/dul1.ark+=13960=t2x41569k-9.png"; 
    232             //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-10.png"; 
    233             //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-1.png"; 
    234             //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-2.png"; 
     233            //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-10.png"; //contentpage 
     234            //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-1.png";  //Image evaluation 
     235            //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-2.png";  //large numbers 
    235236            //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-3.png"; 
    236237            //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-4.png"; 
     
    240241            //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-8.png"; 
    241242            //String default_file = hiresDirectory+"/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-9.png"; 
    242  
    243  
    244  
    245  
    246  
    247  
    248  
    249  
    250  
    251  
    252  
    253  
    254243 
    255244 
     
    268257 
    269258            // Load an image 
    270             Mat original1 = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE); 
    271             System.out.println("Width: " + original1.width() + " Height: " + original1.height()); 
    272             Mat original = original1.clone(); 
     259            Mat original = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE); 
     260            System.out.println("Width: " + original.width() + " Height: " + original.height()); 
     261            Mat binarizedOriginal = original.clone(); 
    273262             
    274             Imgproc.adaptiveThreshold(original1, original,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
     263            Imgproc.adaptiveThreshold(original, binarizedOriginal,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
    275264            //TEST PARAMETERSImgproc.adaptiveThreshold(original, edgesDetected,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 531,1); 
    276265            //Imgproc.threshold(original,original, 127, 255, Imgproc.THRESH_BINARY); 
     
    286275            //dynamic morphology?? 
    287276            if(CODE_VERSION == 1) { 
    288                 int hori = original.width(); 
    289                 int vert = original.height(); 
     277                int hori = binarizedOriginal.width(); 
     278                int vert = binarizedOriginal.height(); 
    290279                //Find ratio between 100 and width and 100 and height 
    291280                int divX = hori/10; 
     
    294283                int sizeY = (vert/divY) * 10; 
    295284 
    296                 Mat test = original.clone(); 
     285                Mat test = binarizedOriginal.clone(); 
    297286                imageViewer("Original", test); 
    298287 
     
    336325 
    337326                //MAKE SURE BLACK & WHITE 
    338                 Mat test = original.clone(); 
     327                Mat test = binarizedOriginal.clone(); 
    339328                imageViewer("00 Binarized Original", test); 
    340329 
     
    377366            //Tutorial/Demo Code 
    378367            if (CODE_VERSION == 3) { 
    379                 Mat horizontal = original.clone(); 
    380                 Mat vertical = original.clone(); 
     368                Mat horizontal = binarizedOriginal.clone(); 
     369                Mat vertical = binarizedOriginal.clone(); 
    381370                // Specify size on horizontal axis 
    382371                int horizontal_size = horizontal.cols() / 50; 
     
    429418 
    430419                //Display Original 
    431                 imageViewer("original", original1); 
    432  
    433                 Mat test = original.clone(); 
    434                 Mat pre = original.clone(); 
     420                imageViewer("original", original); 
     421 
     422                Mat test = binarizedOriginal.clone(); 
     423                Mat pre = binarizedOriginal.clone(); 
    435424                Mat dst = new Mat(); 
    436425 
     
    545534            //Better morphology attempt - dynamic 
    546535            if(CODE_VERSION == 5) { 
    547                 int hori = original.width(); 
    548                 int vert = original.height(); 
     536                int hori = binarizedOriginal.width(); 
     537                int vert = binarizedOriginal.height(); 
    549538                //Find ratio between 100 and width and 100 and height 
    550539                int sizeX100 = 10 * (hori/68); 
     
    560549                System.out.println(hori + " " + vert + " "  + sizeX1 + " " + sizeY1); 
    561550                //Display Original 
    562                 imageViewer("original", original1); 
    563  
    564                 Mat test = original.clone(); 
     551                imageViewer("original", original); 
     552 
     553                Mat test = binarizedOriginal.clone(); 
    565554                imageViewer("00 Inverse Binarized Original", test); 
    566555 
     
    629618                //Get source image and binerize 
    630619                Mat src = Imgcodecs.imread(path, Imgcodecs.IMREAD_GRAYSCALE); 
    631                 Imgproc.adaptiveThreshold(original1, src,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
     620                Imgproc.adaptiveThreshold(original, src,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
    632621                imageViewer("src", src); 
    633622 
     
    652641 
    653642                //Display Original 
    654                 imageViewer("original", original1); 
    655  
    656                 Mat src = original.clone(); 
    657                 Mat test = original.clone(); 
     643                imageViewer("original", original); 
     644 
     645                Mat src = binarizedOriginal.clone(); 
     646                Mat test = binarizedOriginal.clone(); 
    658647                Mat mask = new Mat(); 
    659648                Mat dst = new Mat(); 
     
    738727 
    739728                //Display Original 
    740                 imageViewer("original", original1); 
    741  
    742                 Mat test = original.clone(); 
     729                imageViewer("original", original); 
     730 
     731                Mat test = binarizedOriginal.clone(); 
    743732 
    744733 
     
    749738                //Large Object Removal 
    750739                //************************************ 
    751                 Mat srcLOR = original.clone(); 
     740                Mat srcLOR = binarizedOriginal.clone(); 
    752741                Mat maskLOR = new Mat(); 
    753742                Mat dstLOR = new Mat(); 
     
    976965                    //Imgproc.adaptiveThreshold(original1, original,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C); 
    977966 
    978                     Mat test = original.clone(); 
     967                    Mat test = binarizedOriginal.clone(); 
    979968                    //************************************ 
    980969                    //Large Object Removal 
    981970                    //************************************ 
    982                     Mat srcLOR = original.clone(); 
     971                    Mat srcLOR = binarizedOriginal.clone(); 
    983972                    Mat maskLOR = new Mat(); 
    984973                    Mat dstLOR = new Mat(); 
     
    11661155            //Reset after david chat 
    11671156            if(CODE_VERSION == 9){ 
    1168                 //1. Remove large items (needs to be larger kernel, should not remove bar lines) 
    1169                 //2. Remove text 
    1170                 //3. Standard plan from presentation 
     1157                //Display Original 
     1158                imageViewer("original", original); 
     1159                Mat base = binarizedOriginal.clone(); 
     1160                imageViewer("00 Inverse Binarized Original", base); 
     1161 
     1162 
     1163                //************************************ 
     1164                //1. Large object Remover 
     1165                //************************************ 
     1166                Mat srcLOR = binarizedOriginal.clone(); 
     1167                Mat maskLOR = new Mat(); 
     1168                Mat dstLOR = new Mat(); 
     1169 
     1170                //Remove small objects in prep for masking  (De-Noise) 
     1171                Mat removeSmallLOR = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(5,5)); 
     1172                Imgproc.morphologyEx(srcLOR,maskLOR, Imgproc.MORPH_OPEN, removeSmallLOR); 
     1173                imageViewer("001 De-noise", maskLOR); 
     1174 
     1175                //heal the large items 
     1176                Mat healLOR = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,10)); 
     1177                Imgproc.morphologyEx(maskLOR,maskLOR, Imgproc.MORPH_CLOSE, healLOR); 
     1178                imageViewer("002 heal objects in mask", maskLOR); 
     1179 
     1180                //IsolateLarge 
     1181                Mat isolateLargeLOR = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(20,20)); 
     1182                Imgproc.erode(maskLOR,maskLOR,isolateLargeLOR); 
     1183                imageViewer("003 Isolate large", maskLOR); 
     1184 
     1185                Core.bitwise_not(maskLOR,maskLOR); 
     1186                srcLOR.copyTo(dstLOR, maskLOR); 
     1187                imageViewer("100 Large Items Removed", dstLOR); 
     1188 
     1189                //*********************************** 
     1190                //2. Text-sized Object Removal 
     1191                //*********************************** 
     1192 
     1193                Mat srcTOR = dstLOR.clone(); 
     1194                Mat maskTOR = new Mat(); 
     1195                Mat dstTOR = new Mat(); 
     1196 
     1197                //Remove small objects in prep for masking (De-Noise) 
     1198                Mat removeSmallTOR = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(5,5)); 
     1199                Imgproc.morphologyEx(srcTOR,maskTOR, Imgproc.MORPH_OPEN, removeSmallTOR); 
     1200                imageViewer("101 Remove Small from mask", maskTOR); 
     1201 
     1202                //heal the large items 
     1203                Mat healTOR = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,10)); 
     1204                Imgproc.morphologyEx(maskTOR,maskTOR, Imgproc.MORPH_CLOSE, healTOR); 
     1205                imageViewer("102 heal objects in mask", maskTOR); 
     1206 
     1207                //Highlight black outline 
     1208                Mat highlightLargeTOR = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,10)); 
     1209                Imgproc.erode(maskTOR,maskTOR,highlightLargeTOR); 
     1210                imageViewer("103 highlight objects", maskTOR); 
     1211 
     1212                Core.bitwise_not(maskTOR, maskTOR); 
     1213                srcTOR.copyTo(dstTOR, maskTOR); 
     1214                imageViewer("200 Black outline Removed", dstTOR); 
     1215 
     1216                //*********************************** 
     1217                //3. Standard plan from presentation (TAKEN FROM CODE VERSION 5) 
     1218                //*********************************** 
     1219                Mat kernelErode = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(20,2)); 
     1220                Imgproc.erode(dstTOR,base,kernelErode); 
     1221                imageViewer("201 Erode plus pre", base); 
     1222 
     1223                Mat kernelDilate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(20,2)); 
     1224                Imgproc.dilate(base,base,kernelDilate); 
     1225                imageViewer("202 Dilate", base); 
     1226 
     1227                Mat kernelClosing = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(20,5)); 
     1228                Imgproc.morphologyEx(base, base, Imgproc.MORPH_CLOSE, kernelClosing); 
     1229                imageViewer("203 Close", base); 
     1230 
     1231                Mat kernelErode02 = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,2)); 
     1232                Imgproc.erode(base,base,kernelErode02); 
     1233                imageViewer("204 Erode (Final)", base); 
     1234 
    11711235                //4. Classify like line clusters. 
    11721236            }