Index: /other-projects/is-sheet-music-encore/trunk/Makefile
===================================================================
--- /other-projects/is-sheet-music-encore/trunk/Makefile	(revision 33446)
+++ /other-projects/is-sheet-music-encore/trunk/Makefile	(revision 33447)
@@ -27,15 +27,23 @@
 	
 	
-run-morphology-100-test:
-	cd image-identification-terminal/log-all-hires-new; rm log-morphology-MU-test.txt
-	cd image-identification-terminal; javac javaAccuracyCalculator.java
-	cd image-identification-terminal; javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java;
-	cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU morphology log-all-hires-new/log-morphology-MU-test.txt -testNew
-	cd image-identification-terminal; java javaAccuracyCalculator log-all-hires-new/log-morphology-MU-test.txt morphology-MU log-all-hires-new/results.txt
-	cd image-identification-terminal; less log-all-hires-new/results.txt 
-	cd image-identification-terminal; less log-all-hires-new/log-morphology-MU-test.txt
+run-morphology-20-test:
+	#cd image-identification-terminal/log-all-hires-new/test; rm log-morphology-MU-test.txt
+	cd image-identification-terminal; javac javaAccuracyCalculator.java
+	cd image-identification-terminal; javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java;
+	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
+	cd image-identification-terminal; date >> log-all-hires-new/test/results.txt
+	cd image-identification-terminal; cat configClassifierComparison.properties >> log-all-hires-new/test/results.txt
+	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
+	cd image-identification-terminal; less log-all-hires-new/test/results.txt 
+	cd image-identification-terminal; less log-all-hires-new/test/log-morphology-MU-test.txt
 
 run-morph-single:
 	cd image-identification-terminal; make testrun-classifier-single-morph
+run-count-single:
+	cd image-identification-terminal; make testrun-classifier-single-count
+run-cluster-single:
+	cd image-identification-terminal; make testrun-classifier-single-cluster
+run-combo-single:
+	cd image-identification-terminal; make testrun-classifier-single-combo
 #**********
 #HI-RES
Index: /other-projects/is-sheet-music-encore/trunk/image-identification-dev-02/.idea/workspace.xml
===================================================================
--- /other-projects/is-sheet-music-encore/trunk/image-identification-dev-02/.idea/workspace.xml	(revision 33446)
+++ /other-projects/is-sheet-music-encore/trunk/image-identification-dev-02/.idea/workspace.xml	(revision 33447)
@@ -15,6 +15,6 @@
         <entry file="file://$PROJECT_DIR$/image-identification-development/src/Main.java">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="3154">
-              <caret line="820" column="49" selection-start-line="820" selection-start-column="49" selection-end-line="820" selection-end-column="49" />
+            <state relative-caret-position="-969">
+              <caret line="803" selection-start-line="803" selection-end-line="803" />
               <folding>
                 <element signature="imports" expanded="true" />
@@ -40,18 +40,24 @@
         <entry file="file://$PROJECT_DIR$/image-identification-development/src/MainMorph.java">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="221">
-              <caret line="182" column="12" selection-start-line="182" selection-start-column="12" selection-end-line="182" selection-end-column="12" />
+            <state relative-caret-position="321">
+              <caret line="855" column="42" selection-start-line="855" selection-start-column="42" selection-end-line="855" selection-end-column="42" />
               <folding>
                 <element signature="imports" expanded="true" />
-                <element signature="e#7379#7795#1" />
-                <element signature="e#7580#7900#1" />
-                <element signature="e#11581#14087#1" />
-                <element signature="e#14171#16210#1" />
-                <element signature="e#16278#18925#1" />
-                <element signature="e#19007#24734#1" />
-                <element signature="e#24817#28826#1" />
-                <element signature="e#28892#30082#1" />
-                <element signature="e#30149#34144#1" />
-                <element signature="e#34814#34826#0" expanded="true" />
+                <element signature="e#10614#13084#1" />
+                <element signature="e#13169#15172#1" />
+                <element signature="e#15241#17864#1" />
+                <element signature="e#17947#23618#1" />
+                <element signature="e#23702#27679#1" />
+                <element signature="e#27746#28924#1" />
+                <element signature="e#28992#32955#1" />
+                <element signature="e#35980#35992#0" expanded="true" />
+                <element signature="e#37714#37726#0" expanded="true" />
+                <element signature="e#37797#37809#0" expanded="true" />
+                <element signature="e#41273#41282#0" expanded="true" />
+                <element signature="e#44803#56145#1" />
+                <element signature="e#48966#48978#0" expanded="true" />
+                <element signature="e#49049#49061#0" expanded="true" />
+                <element signature="e#49131#49143#0" expanded="true" />
+                <element signature="e#52896#52905#0" expanded="true" />
               </folding>
             </state>
@@ -62,13 +68,24 @@
         <entry file="file://$PROJECT_DIR$/../image-identification-terminal/javaClassifierComparison.java">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="4598">
-              <caret line="356" selection-start-line="356" selection-end-line="356" />
+            <state relative-caret-position="406">
+              <caret line="606" column="5" lean-forward="true" selection-start-line="606" selection-start-column="5" selection-end-line="606" selection-end-column="5" />
               <folding>
                 <element signature="imports" expanded="true" />
+                <element signature="method#init#0;class#javaClassifierComparison#0" />
+                <element signature="e#3021#4256#0" />
+                <element signature="class#StartAndEndPoint#0;class#javaClassifierComparison#0" />
+                <element signature="class#Pair#0;class#javaClassifierComparison#0" />
                 <element signature="method#Algorithm_HoughLinesP_Single#0;class#javaClassifierComparison#0" />
                 <element signature="method#Algorithm_HoughLinesP_Combo#0;class#javaClassifierComparison#0" />
+                <element signature="method#Algorithm_Morphology#0;class#javaClassifierComparison#0" />
+                <element signature="method#Algorithm_Morphology#0;class#javaClassifierComparison#0" />
+                <element signature="e#20655#20667#0" expanded="true" />
+                <element signature="e#20738#20750#0" expanded="true" />
+                <element signature="e#20820#20832#0" expanded="true" />
+                <element signature="e#24593#24602#0" expanded="true" />
                 <element signature="method#Classifier_LineCounter#0;class#javaClassifierComparison#0" />
                 <element signature="method#Classifier_ClusterDetection#0;class#javaClassifierComparison#0" />
                 <element signature="method#removeDuplicates#0;class#javaClassifierComparison#0" />
+                <element signature="method#VarianceCalc#0;class#javaClassifierComparison#0" />
                 <element signature="method#lineComparison#0;class#javaClassifierComparison#0" />
                 <element signature="method#ClusterCheck#0;class#javaClassifierComparison#0" />
@@ -86,4 +103,9 @@
       <find>ClassifierLineClusterPt</find>
       <find>Object</find>
+      <find>areaCounter</find>
+      <find>THRESHOLD_AREA_COUNT</find>
+      <find>imageViewer</find>
+      <find>coo.31924062612282-9.png</find>
+      <find>FILLED</find>
     </findStrings>
   </component>
@@ -175,5 +197,5 @@
       <window_info anchor="bottom" id="Message" order="0" />
       <window_info anchor="bottom" id="Find" order="1" weight="0.32962137" />
-      <window_info anchor="bottom" id="Run" order="2" weight="0.2494432" />
+      <window_info anchor="bottom" id="Run" order="2" weight="0.27616927" />
       <window_info anchor="bottom" id="Debug" order="3" weight="0.3997773" />
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
@@ -222,6 +244,6 @@
     <entry file="file://$PROJECT_DIR$/image-identification-development/src/Main.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="3154">
-          <caret line="820" column="49" selection-start-line="820" selection-start-column="49" selection-end-line="820" selection-end-column="49" />
+        <state relative-caret-position="-969">
+          <caret line="803" selection-start-line="803" selection-end-line="803" />
           <folding>
             <element signature="imports" expanded="true" />
@@ -245,13 +267,24 @@
     <entry file="file://$PROJECT_DIR$/../image-identification-terminal/javaClassifierComparison.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="4598">
-          <caret line="356" selection-start-line="356" selection-end-line="356" />
+        <state relative-caret-position="406">
+          <caret line="606" column="5" lean-forward="true" selection-start-line="606" selection-start-column="5" selection-end-line="606" selection-end-column="5" />
           <folding>
             <element signature="imports" expanded="true" />
+            <element signature="method#init#0;class#javaClassifierComparison#0" />
+            <element signature="e#3021#4256#0" />
+            <element signature="class#StartAndEndPoint#0;class#javaClassifierComparison#0" />
+            <element signature="class#Pair#0;class#javaClassifierComparison#0" />
             <element signature="method#Algorithm_HoughLinesP_Single#0;class#javaClassifierComparison#0" />
             <element signature="method#Algorithm_HoughLinesP_Combo#0;class#javaClassifierComparison#0" />
+            <element signature="method#Algorithm_Morphology#0;class#javaClassifierComparison#0" />
+            <element signature="method#Algorithm_Morphology#0;class#javaClassifierComparison#0" />
+            <element signature="e#20655#20667#0" expanded="true" />
+            <element signature="e#20738#20750#0" expanded="true" />
+            <element signature="e#20820#20832#0" expanded="true" />
+            <element signature="e#24593#24602#0" expanded="true" />
             <element signature="method#Classifier_LineCounter#0;class#javaClassifierComparison#0" />
             <element signature="method#Classifier_ClusterDetection#0;class#javaClassifierComparison#0" />
             <element signature="method#removeDuplicates#0;class#javaClassifierComparison#0" />
+            <element signature="method#VarianceCalc#0;class#javaClassifierComparison#0" />
             <element signature="method#lineComparison#0;class#javaClassifierComparison#0" />
             <element signature="method#ClusterCheck#0;class#javaClassifierComparison#0" />
@@ -262,18 +295,24 @@
     <entry file="file://$PROJECT_DIR$/image-identification-development/src/MainMorph.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="221">
-          <caret line="182" column="12" selection-start-line="182" selection-start-column="12" selection-end-line="182" selection-end-column="12" />
+        <state relative-caret-position="321">
+          <caret line="855" column="42" selection-start-line="855" selection-start-column="42" selection-end-line="855" selection-end-column="42" />
           <folding>
             <element signature="imports" expanded="true" />
-            <element signature="e#7379#7795#1" />
-            <element signature="e#7580#7900#1" />
-            <element signature="e#11581#14087#1" />
-            <element signature="e#14171#16210#1" />
-            <element signature="e#16278#18925#1" />
-            <element signature="e#19007#24734#1" />
-            <element signature="e#24817#28826#1" />
-            <element signature="e#28892#30082#1" />
-            <element signature="e#30149#34144#1" />
-            <element signature="e#34814#34826#0" expanded="true" />
+            <element signature="e#10614#13084#1" />
+            <element signature="e#13169#15172#1" />
+            <element signature="e#15241#17864#1" />
+            <element signature="e#17947#23618#1" />
+            <element signature="e#23702#27679#1" />
+            <element signature="e#27746#28924#1" />
+            <element signature="e#28992#32955#1" />
+            <element signature="e#35980#35992#0" expanded="true" />
+            <element signature="e#37714#37726#0" expanded="true" />
+            <element signature="e#37797#37809#0" expanded="true" />
+            <element signature="e#41273#41282#0" expanded="true" />
+            <element signature="e#44803#56145#1" />
+            <element signature="e#48966#48978#0" expanded="true" />
+            <element signature="e#49049#49061#0" expanded="true" />
+            <element signature="e#49131#49143#0" expanded="true" />
+            <element signature="e#52896#52905#0" expanded="true" />
           </folding>
         </state>
Index: /other-projects/is-sheet-music-encore/trunk/image-identification-dev-02/image-identification-development/src/MainMorph.java
===================================================================
--- /other-projects/is-sheet-music-encore/trunk/image-identification-dev-02/image-identification-development/src/MainMorph.java	(revision 33446)
+++ /other-projects/is-sheet-music-encore/trunk/image-identification-dev-02/image-identification-development/src/MainMorph.java	(revision 33447)
@@ -63,11 +63,14 @@
 import org.opencv.imgcodecs.Imgcodecs;
 import org.opencv.imgproc.Imgproc;
+import org.opencv.imgproc.Moments;
 
 import static org.opencv.core.Core.FILLED;
 import static org.opencv.core.CvType.CV_8UC3;
+import static org.opencv.highgui.HighGui.createJFrame;
 import static org.opencv.highgui.HighGui.imshow;
 import static org.opencv.imgcodecs.Imgcodecs.imwrite;
 
 import java.io.File;
+import java.lang.reflect.Array;
 import java.util.ArrayList;
 
@@ -90,4 +93,6 @@
 //https://stackoverflow.com/questions/23327502/opencv-how-to-draw-minarearect-in-java
 //https://stackoverflow.com/questions/30056910/opencv-java-modify-pixel-values
+//https://stackoverflow.com/questions/18345969/how-to-get-the-mass-center-of-a-contour-android-opencv
+//https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_features_harris/py_features_harris.html
 
 
@@ -115,6 +120,6 @@
 
     static double THRESHOLD_C    = 4;
-    static double THRESHOLD_AREA_SIZE  = 1000;
-    static double THRESHOLD_AREA_COUNT = 2;
+    static double THRESHOLD_AREA_SIZE  = 10000;
+    static double THRESHOLD_AREA_COUNT = 10;
 
     //
@@ -153,4 +158,7 @@
         }
     }
+
+
+
     //MAIN
     public static void main(String[] args) {
@@ -158,6 +166,5 @@
         try {
             //Variables
-            System.out.println("Running code version: " + CODE_VERSION);
-            Mat edgesDetected = new Mat();
+            System.out.println("Running Code version: " + CODE_VERSION + " Image Version: " +IMAGE_VERSION);
             Mat mid = new Mat();
             Mat edgesDetectedRGB = new Mat();
@@ -175,11 +182,14 @@
             //String default_file = directory+"NotSheetMusic/coo.31924062612282-9.png";
             //String default_file = directory+"NotSheetMusic/mdp.39015097852365-2.png";
-            //String default_file =testDirectory+"TestImages/NotNot/mdp.39015080972303-3.png"; //WHY GREY?
+            //String default_file =testDirectory+"TestImages/NotNot/mdp.39015080972303-3.png"; //WHY GREY? DUE TO IMAGE LARGE, ZOOM IN
             //String default_file =hiresDirectory+"BK/NotSheetMusic/aeu.ark+=13960=t2q53nq6w-6.png";
             //String default_file =hiresDirectory+"BK/NotSheetMusic/aeu.ark+=13960=t9z03w65z-4.png";
             //String default_file =hiresDirectory+"MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-1.png";
             //String default_file =hiresDirectory+"MU/SheetMusic/emu.010001066823-9.png";
+            //String default_file =hiresDirectory+"MU/SheetMusic/bc.ark+=13960=t2j72dt1p-10.png";
+            //String default_file =hiresDirectory+"MU/SheetMusic/bc.ark+=13960=t2j72dt1p-7.png";
+            String default_file =hiresDirectory+"MU/SheetMusic/coo.31924062612282-9.png";
             //String default_file =hiresDirectory+"MU/NotSheetMusic/mdp.39015096363935-1.png";
-            String default_file =hiresDirectory+"MU/SheetMusic/coo.31924062612282-9.png";
+            //String default_file =hiresDirectory+"MU/SheetMusic/coo.31924062612282-9.png";
 
             //System.out.println(default_file);
@@ -356,5 +366,5 @@
             }
             //Better morphology attempt - static
-            if(CODE_VERSION ==4) {
+            if(CODE_VERSION == 4) {
 
                 //Display Original
@@ -474,5 +484,5 @@
             }
             //Better morphology attempt - dynamic
-            if(CODE_VERSION ==5) {
+            if(CODE_VERSION == 5) {
                 int hori = original.width();
                 int vert = original.height();
@@ -553,5 +563,5 @@
             }
             //MASK UNDERSTANDING
-            if(CODE_VERSION ==6) {
+            if(CODE_VERSION == 6) {
                 String path ="/Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU/NotSheetMusic/aeu.ark+=13960=t0dv28v9r-1.png";
                 Mat mask = new Mat();
@@ -579,5 +589,5 @@
             }
             //Mask implementation
-            if(CODE_VERSION ==7) {
+            if(CODE_VERSION == 7) {
 
                 //Display Original
@@ -664,69 +674,97 @@
 
             }
-            //Mask implementation - HIGH RES NUMBER MOD
-            if(CODE_VERSION ==8) {
+            //Mask implementations (LARGE AND SMALL) - HIGH RES NUMBER MOD
+            if(CODE_VERSION == 8) {
 
                 //Display Original
                 imageViewer("original", original1);
 
-                Mat src = original.clone();
                 Mat test = original.clone();
-                Mat mask = new Mat();
-                Mat dst = new Mat();
-
-                imageViewer("00 Inverse Binarized Original", src);
-
-                //Close then Open
-
-//                Mat firstKernel = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,10));
-//                Imgproc.morphologyEx(src, mask, Imgproc.MORPH_CLOSE, firstKernel);
-//                imageViewer("01 Closed - mask", mask);
-//
-//                Mat secondKernel = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,10));
-//                Imgproc.morphologyEx(src,mask, Imgproc.MORPH_OPEN, secondKernel);
-//                imageViewer("02 Open - mask", mask);
-
+
+
+                imageViewer("00 Inverse Binarized Original", test);
+
+
+                //************************************
+                //Large Object Removal
+                //************************************
+                Mat srcLOR = original.clone();
+                Mat maskLOR = new Mat();
+                Mat dstLOR = new Mat();
 
                 //denoize
                 Mat denoize = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(5,5));
-                Imgproc.morphologyEx(src,mask, Imgproc.MORPH_OPEN, denoize);
-                imageViewer("01 Denoize - mask", mask);
+                Imgproc.morphologyEx(srcLOR,maskLOR, Imgproc.MORPH_OPEN, denoize);
+                imageViewer("01 Denoize - mask", maskLOR);
 
                 //close up gaps
                 Mat gapCloser = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(5,5));
-                Imgproc.morphologyEx(mask,mask,Imgproc.MORPH_CLOSE, gapCloser);
-                imageViewer("02 gap closer - mask", mask);
+                Imgproc.morphologyEx(maskLOR,maskLOR,Imgproc.MORPH_CLOSE, gapCloser);
+                imageViewer("02 gap closer - mask", maskLOR);
 
                 //Isolate large items
                 Mat isolateLarge = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(8, 8));
-                Imgproc.morphologyEx(mask,mask,Imgproc.MORPH_OPEN, isolateLarge);
-                imageViewer("03 Isolate Large - mask", mask);
-                Core.bitwise_not(mask,mask);
-
-                //Remove unwanted large items from image
-                src.copyTo(dst, mask);
-                imageViewer("04 Large Items Removed", dst);
-
+                Imgproc.morphologyEx(maskLOR,maskLOR,Imgproc.MORPH_OPEN, isolateLarge);
+                imageViewer("03 Isolate Large - mask", maskLOR);
+
+                //Remove large items from image
+                Core.bitwise_not(maskLOR,maskLOR);
+                srcLOR.copyTo(dstLOR, maskLOR);
+                imageViewer("04 Large Items Removed", dstLOR);
+
+                //****************************************
+                //Small object removal (SOR)
+                //****************************************
+
+                Mat srcSOR = dstLOR.clone();
+                Mat maskSOR = new Mat();
+                Mat dstSOR = new Mat();
+
+                Mat startSOR =Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(7,7));
+                Imgproc.morphologyEx(srcSOR,maskSOR, Imgproc.MORPH_OPEN, startSOR);
+                imageViewer("11 show small - mask", maskSOR);
+
+                Mat highlightSmall = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(7,7));
+                Imgproc.dilate(maskSOR, maskSOR, highlightSmall);
+                imageViewer("12 highlight small - mask", maskSOR);
+
+/*              Mat isolateSmall =Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,10));
+                Imgproc.morphologyEx(maskSOR,maskSOR,Imgproc.MORPH_CLOSE, isolateSmall);
+                imageViewer("13 isolate small - mask", maskSOR);
+*/
+
+                //Remove small items from image
+                Core.bitwise_not(maskSOR, maskSOR);
+                srcSOR.copyTo(dstSOR, maskSOR);
+                imageViewer("14 Small Items Removed", dstSOR);
+
+
+                //****************************************
                 //start staff line detection
+                //****************************************
 
                 Mat kernelErode = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(15,2)); //10,2
-                Imgproc.erode(dst,test,kernelErode);
-                imageViewer("11 Erode plus pre", test);
+                Imgproc.erode(dstSOR,test,kernelErode);
+                imageViewer("21 Erode plus pre", test);
 
                 Mat kernelDilate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //20,3
                 Imgproc.dilate(test,test,kernelDilate);
-                imageViewer("12 Dilate", test);
-
-                Mat kernelOpening = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //4,4
-                Imgproc.morphologyEx(test, test, Imgproc.MORPH_CLOSE, kernelOpening);
-                imageViewer("13 Open", test);
+                imageViewer("22 Dilate", test);
+
+                Mat kernelClose = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //4,4
+                Imgproc.morphologyEx(test, test, Imgproc.MORPH_CLOSE, kernelClose);
+                imageViewer("23 Close", test);
+
 
                 Mat kernelErode02 = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //10,1
                 Imgproc.erode(test,test,kernelErode02);
-                imageViewer("14 Erode (Final)", test);
-
-
+                imageViewer("24 Erode (Final)", test);
+
+                //********************************************************************************
                 //DETECT OUTLINE AND FIND AREA OF THESE LINES.
+                //********************************************************************************
                 ArrayList<MatOfPoint> contours = new ArrayList<MatOfPoint>();
+                ArrayList<MatOfPoint> largeContours = new ArrayList<MatOfPoint>();
+                ArrayList<MatOfPoint> postContours = new ArrayList<MatOfPoint>();
                 Mat hierarchy = new Mat();
 
@@ -738,6 +776,9 @@
                 Imgproc.findContours(test, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
 
+                System.out.println(contours.size());
                 //Draw contours and record areas
-                Mat drawing = Mat.zeros(test.size(), CvType.CV_8UC3);
+                Mat allContoursFound = Mat.zeros(test.size(), CvType.CV_8UC3);
+                Mat largeContoursFound = allContoursFound.clone() ;
+                Mat postContoursFound = allContoursFound.clone();
                 int areaCounter = 0;
 
@@ -748,13 +789,111 @@
                 //Discuss with david before weekend perhaps?
 
-                Imgproc.drawContours(drawing, contours, -1, new Scalar(0, 255, 0), 1); //USES LINE_8
-//                   for (int i = 0; i < contours.size(); i++) {
-//                    Scalar color = new Scalar(0, i, i);
-//                    double area = Imgproc.contourArea(contours.get(i));
-//                    Imgproc.drawContours(drawing, contours, i, color, FILLED);
-//                    System.out.println("AREA: " + area);
-//
-//                }
-                imageViewer("Contours found", drawing);
+                Imgproc.drawContours(allContoursFound, contours, -1, new Scalar(0, 255, 0), 1); //USES LINE_8
+                for (int i = 0; i < contours.size(); i++) {
+                    double area = Imgproc.contourArea(contours.get(i));
+                    if(area > 100) {
+                        System.out.println("AREA: " + area);
+                        Imgproc.drawContours(largeContoursFound, contours, i, new Scalar(255, 0, 0), FILLED);
+                        //create list of large coutours found
+                        largeContours.add(contours.get(i));
+                    }
+                }
+                imageViewer("80 All Contours found", allContoursFound);
+                imageViewer("81 Large Contours Found", largeContoursFound);
+
+                //*****************************************************************
+                //Circles and centres on processed images
+                //*****************************************************************
+
+                //Init arrays
+                Mat circleOutput = allContoursFound.clone();
+                MatOfPoint2f[] contoursPoly  = new MatOfPoint2f[largeContours.size()];
+                Point[] centers = new Point[largeContours.size()];
+                float[][] radius = new float[largeContours.size()][1];
+
+                //Fill arrays
+                for (int i = 0; i < largeContours.size(); i++) {
+                    contoursPoly[i] = new MatOfPoint2f();
+                    Imgproc.approxPolyDP(new MatOfPoint2f(largeContours.get(i).toArray()), contoursPoly[i], 1, true);
+                    centers[i] = new Point();
+                    Imgproc.minEnclosingCircle(contoursPoly[i], centers[i], radius[i]);
+
+                }
+                //Draw circle for each large contour
+                for (int i = 0; i < largeContours.size(); i++) {
+                    Imgproc.circle(circleOutput, centers[i], (int) radius[i][0],new Scalar(255, 0, 0), 1);
+                }
+                imageViewer("82 Circles found", circleOutput);
+
+                //********************************************************************************
+                //Centroids - Everything must be to scale
+                //********************************************************************************
+
+                ArrayList<Moments> mu = new ArrayList<Moments>(largeContours.size());
+                Mat centreOutput = Mat.zeros(largeContoursFound.size(), CvType.CV_8UC3);
+                for (int i = 0; i < largeContours.size(); i++) {
+                    mu.add(i, Imgproc.moments(largeContours.get(i), false));
+                    Moments p = mu.get(i);
+                    int x = (int) (p.get_m10() / p.get_m00());
+                    int y = (int) (p.get_m01() / p.get_m00());
+                    Imgproc.circle(centreOutput, new Point(x, y), 4, new Scalar(255, 255, 255), 30);
+                }
+                imageViewer("83 Centres found", centreOutput);
+
+
+                //***********************************************
+                //PostProcessing - Morphology Classifier
+                //  Use dilation to "Connect the dots"
+                //  Testing showed the centroids were clustered together
+                //  Then use area or perimeter as a classifier filter
+                //REFINEREFINEREIFEN
+                //REFINEREFINEREIFEN
+                //REFINEREFINEREIFEN
+                //REFINEREFINEREIFEN
+                //REFINEREFINEREIFEN
+                //REFINEREFINEREIFEN
+                // FIX UP CLASSIFIER COMPARISON.
+                // MORPHOLOGIES FUNCTIONS RETURN NULL AS THEIR RETURN VARIABLES. WHY?
+                //REFINEREFINEREIFEN
+                //REFINEREFINEREIFEN
+                //REFINEREFINEREIFEN
+                //REFINEREFINEREIFEN
+                //REFINEREFINEREIFEN
+                //***********************************************
+
+                Mat postDilate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(150,15));
+                Imgproc.dilate(centreOutput,centreOutput,postDilate);
+                imageViewer("91 PostDilated", centreOutput);
+
+                Mat postClose = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //4,4
+                Imgproc.morphologyEx(centreOutput, centreOutput, Imgproc.MORPH_CLOSE, postClose);
+                imageViewer("92 PostClose", centreOutput);
+
+                Mat postDenoize = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(100,100));
+                Imgproc.morphologyEx(centreOutput,centreOutput, Imgproc.MORPH_OPEN, postDenoize);
+                imageViewer("93 PostDenoize", centreOutput);
+
+                //Mat postOutline = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(50,50));
+                //Imgproc.morphologyEx(centreOutput, centreOutput, Imgproc.MORPH_GRADIENT, postOutline);
+
+
+
+                //Find area
+                Mat centreOutputGrey = new Mat();
+                Imgproc.cvtColor(centreOutput, centreOutputGrey, Imgproc.COLOR_RGB2GRAY);
+                Imgproc.findContours(centreOutputGrey, postContours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
+
+                for (int i = 0; i < postContours.size(); i++) {
+                    double area = Imgproc.contourArea(postContours.get(i));
+                    if(area > THRESHOLD_AREA_SIZE) {
+                        System.out.println("POST AREA: " + area);
+                        Imgproc.drawContours(postContoursFound, postContours, i, new Scalar(0, 255, 0), FILLED);
+                        areaCounter++;
+                    }
+                }
+
+
+
+                imageViewer("93 PostEND", postContoursFound);
 
                 //Classifier Calculation
@@ -766,4 +905,225 @@
 
             }
+            //ClassifierComparison - Using code version 8
+            if(CODE_VERSION == 81) {
+
+                //Display Original
+                //imageViewer("original", original1);
+
+                Mat test = original.clone();
+
+
+                //imageViewer("00 Inverse Binarized Original", test);
+
+
+                //************************************
+                //Large Object Removal
+                //************************************
+                Mat srcLOR = original.clone();
+                Mat maskLOR = new Mat();
+                Mat dstLOR = new Mat();
+
+                //denoize
+                Mat denoize = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(5,5));
+                Imgproc.morphologyEx(srcLOR,maskLOR, Imgproc.MORPH_OPEN, denoize);
+                //imageViewer("01 Denoize - mask", maskLOR);
+
+                //close up gaps
+                Mat gapCloser = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(5,5));
+                Imgproc.morphologyEx(maskLOR,maskLOR,Imgproc.MORPH_CLOSE, gapCloser);
+                //imageViewer("02 gap closer - mask", maskLOR);
+
+                //Isolate large items
+                Mat isolateLarge = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(8, 8));
+                Imgproc.morphologyEx(maskLOR,maskLOR,Imgproc.MORPH_OPEN, isolateLarge);
+                //imageViewer("03 Isolate Large - mask", maskLOR);
+
+                //Remove large items from image
+                Core.bitwise_not(maskLOR,maskLOR);
+                srcLOR.copyTo(dstLOR, maskLOR);
+                //imageViewer("04 Large Items Removed", dstLOR);
+
+                //****************************************
+                //Small object removal (SOR)
+                //****************************************
+
+                Mat srcSOR = dstLOR.clone();
+                Mat maskSOR = new Mat();
+                Mat dstSOR = new Mat();
+
+                Mat startSOR =Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(7,7));
+                Imgproc.morphologyEx(srcSOR,maskSOR, Imgproc.MORPH_OPEN, startSOR);
+                //imageViewer("11 show small - mask", maskSOR);
+
+                Mat highlightSmall = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(7,7));
+                Imgproc.dilate(maskSOR, maskSOR, highlightSmall);
+                //imageViewer("12 highlight small - mask", maskSOR);
+
+/*              Mat isolateSmall =Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,10));
+                Imgproc.morphologyEx(maskSOR,maskSOR,Imgproc.MORPH_CLOSE, isolateSmall);
+                imageViewer("13 isolate small - mask", maskSOR);
+*/
+
+                //Remove small items from image
+                Core.bitwise_not(maskSOR, maskSOR);
+                srcSOR.copyTo(dstSOR, maskSOR);
+                //imageViewer("14 Small Items Removed", dstSOR);
+
+
+                //****************************************
+                //start staff line detection
+                //****************************************
+
+                Mat kernelErode = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(15,2)); //10,2
+                Imgproc.erode(dstSOR,test,kernelErode);
+                //imageViewer("21 Erode plus pre", test);
+
+                Mat kernelDilate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //20,3
+                Imgproc.dilate(test,test,kernelDilate);
+                //imageViewer("22 Dilate", test);
+
+                Mat kernelClose = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //4,4
+                Imgproc.morphologyEx(test, test, Imgproc.MORPH_CLOSE, kernelClose);
+                //imageViewer("23 Close", test);
+
+
+                Mat kernelErode02 = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //10,1
+                Imgproc.erode(test,test,kernelErode02);
+                //imageViewer("24 Erode (Final)", test);
+
+                //********************************************************************************
+                //DETECT OUTLINE AND FIND AREA OF THESE LINES.
+                //********************************************************************************
+                ArrayList<MatOfPoint> contours = new ArrayList<MatOfPoint>();
+                ArrayList<MatOfPoint> largeContours = new ArrayList<MatOfPoint>();
+                ArrayList<MatOfPoint> postContours = new ArrayList<MatOfPoint>();
+                Mat hierarchy = new Mat();
+
+                //PARAMETERS: input image, output array of arrays, output array, contour retrieval mode, contour approximation method.
+                //(contours)  output array of arrays: Detected contours. Each contour is stored as a vector of points
+                //(hierarchy) output array:           Optional output vector, containing information about the image topology.
+                //https://docs.opencv.org/3.3.1/d3/dc0/group__imgproc__shape.html#ga17ed9f5d79ae97bd4c7cf18403e1689a
+
+                Imgproc.findContours(test, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
+
+                System.out.println(contours.size());
+                //Draw contours and record areas
+                Mat allContoursFound = Mat.zeros(test.size(), CvType.CV_8UC3);
+                Mat largeContoursFound = allContoursFound.clone() ;
+                Mat postContoursFound = allContoursFound.clone();
+                int areaCounter = 0;
+
+                //Have created a preprocess to remove large objects.
+                //Need to now finalized Classifier, re try area detection.
+                //Paths to take - rectangle boxes around detected contours over threshold (area or perimeter)
+                //Just use area and periemter to determine if sheet music
+                //Discuss with david before weekend perhaps?
+
+                Imgproc.drawContours(allContoursFound, contours, -1, new Scalar(0, 255, 0), 1); //USES LINE_8
+                for (int i = 0; i < contours.size(); i++) {
+                    double area = Imgproc.contourArea(contours.get(i));
+                    if(area > 100) {
+                        //System.out.println("AREA: " + area);
+                        Imgproc.drawContours(largeContoursFound, contours, i, new Scalar(255, 0, 0), FILLED);
+                        //create list of large coutours found
+                        largeContours.add(contours.get(i));
+                    }
+                }
+                //imageViewer("80 All Contours found", allContoursFound);
+                //imageViewer("81 Large Contours Found", largeContoursFound);
+
+                //*****************************************************************
+                //Circles and centres on processed images
+                //*****************************************************************
+
+                //Init arrays
+                Mat circleOutput = allContoursFound.clone();
+                MatOfPoint2f[] contoursPoly  = new MatOfPoint2f[largeContours.size()];
+                Point[] centers = new Point[largeContours.size()];
+                float[][] radius = new float[largeContours.size()][1];
+
+                //Fill arrays
+                for (int i = 0; i < largeContours.size(); i++) {
+                    contoursPoly[i] = new MatOfPoint2f();
+                    Imgproc.approxPolyDP(new MatOfPoint2f(largeContours.get(i).toArray()), contoursPoly[i], 1, true);
+                    centers[i] = new Point();
+                    Imgproc.minEnclosingCircle(contoursPoly[i], centers[i], radius[i]);
+
+                }
+                //Draw circle for each large contour
+                for (int i = 0; i < largeContours.size(); i++) {
+                    Imgproc.circle(circleOutput, centers[i], (int) radius[i][0],new Scalar(255, 0, 0), 1);
+                }
+                //imageViewer("82 Circles found", circleOutput);
+
+                //********************************************************************************
+                //Centroids - Everything must be to scale
+                //********************************************************************************
+
+                ArrayList<Moments> mu = new ArrayList<Moments>(largeContours.size());
+                Mat centreOutput = Mat.zeros(largeContoursFound.size(), CvType.CV_8UC3);
+                for (int i = 0; i < largeContours.size(); i++) {
+                    mu.add(i, Imgproc.moments(largeContours.get(i), false));
+                    Moments p = mu.get(i);
+                    int x = (int) (p.get_m10() / p.get_m00());
+                    int y = (int) (p.get_m01() / p.get_m00());
+                    Imgproc.circle(centreOutput, new Point(x, y), 4, new Scalar(255, 255, 255), 30);
+                }
+                //imageViewer("83 Centres found", centreOutput);
+
+
+                //***********************************************
+                //PostProcessing - Morphology Classifier
+                //  Use dilation to "Connect the dots"
+                //  Testing showed the centroids were clustered together
+                //  Then use area or perimeter as a classifier filter
+                //REFINEREFINEREIFEN
+                //REFINEREFINEREIFEN
+                //REFINEREFINEREIFEN
+                //REFINEREFINEREIFEN
+                //REFINEREFINEREIFEN
+                //REFINEREFINEREIFEN
+                //***********************************************
+
+                Mat postDilate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(150,15));
+                Imgproc.dilate(centreOutput,centreOutput,postDilate);
+                //imageViewer("91 PostDilated", centreOutput);
+
+                Mat postClose = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //4,4
+                Imgproc.morphologyEx(centreOutput, centreOutput, Imgproc.MORPH_CLOSE, postClose);
+                //imageViewer("92 PostClose", centreOutput);
+
+                Mat postDenoize = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(100,100));
+                Imgproc.morphologyEx(centreOutput,centreOutput, Imgproc.MORPH_OPEN, postDenoize);
+                //imageViewer("93 PostDenoize", centreOutput);
+
+                //Mat postOutline = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(50,50));
+                //Imgproc.morphologyEx(centreOutput, centreOutput, Imgproc.MORPH_GRADIENT, postOutline);
+
+
+
+                //Find area
+                Mat centreOutputGrey = new Mat();
+                Imgproc.cvtColor(centreOutput, centreOutputGrey, Imgproc.COLOR_RGB2GRAY);
+                Imgproc.findContours(centreOutputGrey, postContours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
+
+                for (int i = 0; i < postContours.size(); i++) {
+                    double area = Imgproc.contourArea(postContours.get(i));
+                    if(area > 10000) {
+                        //System.out.println("POST AREA: " + area);
+                        Imgproc.drawContours(postContoursFound, postContours, i, new Scalar(0, 255, 0), FILLED);
+                        areaCounter++;
+                    }
+                }
+                //imageViewer("93 PostEND", postContoursFound);
+
+                //Classifier Calculation
+                if(areaCounter >= THRESHOLD_AREA_COUNT){
+                    //System.out.println("THIS IS SHEET MUSIC");
+                    //System.out.println(areaCounter);
+                }
+
+
+            }
 
             //USE stuc element, to rule out large wide and long pieces of black and white.
@@ -779,6 +1139,6 @@
 
 
-            imshow("LINESFOUND", edgesDetectedRGB);
-            HighGui.resizeWindow("LINESFOUND", 1000,1000);
+            //imshow("LINESFOUND", edgesDetectedRGB);
+            //HighGui.resizeWindow("LINESFOUND", 1000,1000);
             
             //HighGui.imshow("CLUSTERS FOUND", clustersFoundRGB);
@@ -793,5 +1153,5 @@
 
             // Wait and Exit
-            HighGui.waitKey();
+            //HighGui.waitKey();
             System.exit(0);
         }
Index: /other-projects/is-sheet-music-encore/trunk/image-identification-terminal/Makefile
===================================================================
--- /other-projects/is-sheet-music-encore/trunk/image-identification-terminal/Makefile	(revision 33446)
+++ /other-projects/is-sheet-music-encore/trunk/image-identification-terminal/Makefile	(revision 33447)
@@ -35,12 +35,20 @@
 	less logSingle.txt
 	
+testrun-classifier-single-combo:
+	./runClassifer.sh TestImages/test-coo.31924062612282-9.png combo logSingle.txt -singleNew
+	echo "Displaying javaImageClassifier output"
+        #Calculate the Accuracy of the classifier
+	java javaAccuracyCalculator logSingle.txt houghlinesP resultSingle.txt
+        #Display output
+	less logSingle.txt
+	
 testrun-classifier-single-morph:
 	javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaClassifierComparison.java;
-	./runClassifer.sh TestImages/test-coo.31924062612282-9.png morphology logSingle.txt -singleNew
+	./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/hires-download-images/MU/SheetMusic/coo.31924062612282-9.png morphology log-all-hires-new/test/logSingle.txt -singleNew
 	echo "Displaying javaImageClassifier output"
         #Calculate the Accuracy of the classifier
-	java javaAccuracyCalculator logSingle.txt morphology resultSingle.txt
+	java javaAccuracyCalculator log-all-hires-new/test/logSingle.txt morphology-MU log-all-hires-new/test/resultSingle.txt
         #Display output
-	less logSingle.txt
+	less log-all-hires-new/test/logSingle.txt
 
 
Index: /other-projects/is-sheet-music-encore/trunk/image-identification-terminal/configClassifierComparison.properties
===================================================================
--- /other-projects/is-sheet-music-encore/trunk/image-identification-terminal/configClassifierComparison.properties	(revision 33446)
+++ /other-projects/is-sheet-music-encore/trunk/image-identification-terminal/configClassifierComparison.properties	(revision 33447)
@@ -13,6 +13,6 @@
 CLUSTER_DISTANCE_MIN			= 2
 #MORPHOLOGY
-THRESHOLD_AREA_SIZE			= 1000
-THRESHOLD_AREA_COUNT			= 4
+THRESHOLD_AREA_SIZE			= 10000
+THRESHOLD_AREA_COUNT			= 10
 
 
Index: /other-projects/is-sheet-music-encore/trunk/image-identification-terminal/javaClassifierComparison.java
===================================================================
--- /other-projects/is-sheet-music-encore/trunk/image-identification-terminal/javaClassifierComparison.java	(revision 33446)
+++ /other-projects/is-sheet-music-encore/trunk/image-identification-terminal/javaClassifierComparison.java	(revision 33447)
@@ -1,3 +1,2 @@
-
 import org.opencv.core.*;
 import org.opencv.core.Point;
@@ -5,5 +4,7 @@
 import org.opencv.imgcodecs.Imgcodecs;
 import org.opencv.imgproc.Imgproc;
-import static org.opencv.imgcodecs.Imgcodecs.imwrite;
+import org.opencv.imgproc.Moments;
+//import org.opencv.core.Core.FILLED;
+//import org.opencv.imgcodecs.Imgcodecs.imwrite;
 import java.awt.image.BufferedImage;
 import java.awt.image.DataBufferByte;
@@ -200,5 +201,5 @@
                         break;
                     case "morphology":
-                        algorithmResult = Algorithm_Morphology(imageFilename);
+                        algorithmResult = Algorithm_MorphologyOLD(imageFilename);
                         bw.write("Filename:" + '\t' + imageFilename + '\t' + "Classified as:" + '\t' + algorithmResult.getBoolean() + '\t' + "Number of areas:" + '\t' + algorithmResult.getInteger() + '\t' + classifierType + '\n');
                         break;
@@ -324,5 +325,6 @@
         return returnVariables;
     }
-    private static Pair Algorithm_Morphology(String filename){
+    private static Pair Algorithm_MorphologyOLD(String filename){
+
         System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
         Boolean isSheetMusic = null;
@@ -365,4 +367,10 @@
                 }
             }
+
+
+
+
+
+
             //Calculates if sheet music or not
             if(areaCounter >= THRESHOLD_AREA_COUNT){
@@ -376,5 +384,226 @@
         return returnVariables;
     }
-
+    private static Pair Algorithm_Morphology(String filename){
+
+        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
+        Boolean isSheetMusic = null;
+        Pair returnVariables = new Pair();
+        try{
+            int FILLED = -1;
+            //Display Original
+            //imageViewer("original", original1);
+            Mat original = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE);
+            Mat test = original.clone();
+            //imageViewer("00 Inverse Binarized Original", test);
+
+
+            //************************************
+            //Large Object Removal
+            //************************************
+            Mat srcLOR = original.clone();
+            Mat maskLOR = new Mat();
+            Mat dstLOR = new Mat();
+
+            //denoize
+            Mat denoize = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(5,5));
+            Imgproc.morphologyEx(srcLOR,maskLOR, Imgproc.MORPH_OPEN, denoize);
+            //imageViewer("01 Denoize - mask", maskLOR);
+
+            //close up gaps
+            Mat gapCloser = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(5,5));
+            Imgproc.morphologyEx(maskLOR,maskLOR,Imgproc.MORPH_CLOSE, gapCloser);
+            //imageViewer("02 gap closer - mask", maskLOR);
+
+            //Isolate large items
+            Mat isolateLarge = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(8, 8));
+            Imgproc.morphologyEx(maskLOR,maskLOR,Imgproc.MORPH_OPEN, isolateLarge);
+            //imageViewer("03 Isolate Large - mask", maskLOR);
+
+            //Remove large items from image
+            Core.bitwise_not(maskLOR,maskLOR);
+            srcLOR.copyTo(dstLOR, maskLOR);
+            //imageViewer("04 Large Items Removed", dstLOR);
+
+            //****************************************
+            //Small object removal (SOR)
+            //****************************************
+
+            Mat srcSOR = dstLOR.clone();
+            Mat maskSOR = new Mat();
+            Mat dstSOR = new Mat();
+
+            Mat startSOR =Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(7,7));
+            Imgproc.morphologyEx(srcSOR,maskSOR, Imgproc.MORPH_OPEN, startSOR);
+            //imageViewer("11 show small - mask", maskSOR);
+
+            Mat highlightSmall = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(7,7));
+            Imgproc.dilate(maskSOR, maskSOR, highlightSmall);
+            //imageViewer("12 highlight small - mask", maskSOR);
+
+/*              Mat isolateSmall =Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,10));
+                Imgproc.morphologyEx(maskSOR,maskSOR,Imgproc.MORPH_CLOSE, isolateSmall);
+                imageViewer("13 isolate small - mask", maskSOR);
+*/
+
+            //Remove small items from image
+            Core.bitwise_not(maskSOR, maskSOR);
+            srcSOR.copyTo(dstSOR, maskSOR);
+            //imageViewer("14 Small Items Removed", dstSOR);
+
+
+            //****************************************
+            //start staff line detection
+            //****************************************
+
+            Mat kernelErode = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(15,2)); //10,2
+            Imgproc.erode(dstSOR,test,kernelErode);
+            //imageViewer("21 Erode plus pre", test);
+
+            Mat kernelDilate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //20,3
+            Imgproc.dilate(test,test,kernelDilate);
+            //imageViewer("22 Dilate", test);
+
+            Mat kernelClose = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //4,4
+            Imgproc.morphologyEx(test, test, Imgproc.MORPH_CLOSE, kernelClose);
+            //imageViewer("23 Close", test);
+
+
+            Mat kernelErode02 = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //10,1
+            Imgproc.erode(test,test,kernelErode02);
+            //imageViewer("24 Erode (Final)", test);
+
+            //********************************************************************************
+            //DETECT OUTLINE AND FIND AREA OF THESE LINES.
+            //********************************************************************************
+            ArrayList<MatOfPoint> contours = new ArrayList<MatOfPoint>();
+            ArrayList<MatOfPoint> largeContours = new ArrayList<MatOfPoint>();
+            ArrayList<MatOfPoint> postContours = new ArrayList<MatOfPoint>();
+            Mat hierarchy = new Mat();
+
+            //PARAMETERS: input image, output array of arrays, output array, contour retrieval mode, contour approximation method.
+            //(contours)  output array of arrays: Detected contours. Each contour is stored as a vector of points
+            //(hierarchy) output array:           Optional output vector, containing information about the image topology.
+            //https://docs.opencv.org/3.3.1/d3/dc0/group__imgproc__shape.html#ga17ed9f5d79ae97bd4c7cf18403e1689a
+
+            Imgproc.findContours(test, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
+
+            System.out.println(contours.size());
+            //Draw contours and record areas
+            Mat allContoursFound = Mat.zeros(test.size(), CvType.CV_8UC3);
+            Mat largeContoursFound = allContoursFound.clone() ;
+            Mat postContoursFound = allContoursFound.clone();
+            int areaCounter = 0;
+
+            //Have created a preprocess to remove large objects.
+            //Need to now finalized Classifier, re try area detection.
+            //Paths to take - rectangle boxes around detected contours over threshold (area or perimeter)
+            //Just use area and periemter to determine if sheet music
+            //Discuss with david before weekend perhaps?
+
+            Imgproc.drawContours(allContoursFound, contours, -1, new Scalar(0, 255, 0), 1); //USES LINE_8
+            for (int i = 0; i < contours.size(); i++) {
+                double area = Imgproc.contourArea(contours.get(i));
+                if(area > 100) {
+                    //System.out.println("AREA: " + area);
+                    Imgproc.drawContours(largeContoursFound, contours, i, new Scalar(255, 0, 0), FILLED);
+                    //create list of large coutours found
+                    largeContours.add(contours.get(i));
+                }
+            }
+            //imageViewer("80 All Contours found", allContoursFound);
+            //imageViewer("81 Large Contours Found", largeContoursFound);
+
+            //*****************************************************************
+            //Circles and centres on processed images
+            //*****************************************************************
+
+            //Init arrays
+            Mat circleOutput = allContoursFound.clone();
+            MatOfPoint2f[] contoursPoly  = new MatOfPoint2f[largeContours.size()];
+            Point[] centers = new Point[largeContours.size()];
+            float[][] radius = new float[largeContours.size()][1];
+
+            //Fill arrays
+            for (int i = 0; i < largeContours.size(); i++) {
+                contoursPoly[i] = new MatOfPoint2f();
+                Imgproc.approxPolyDP(new MatOfPoint2f(largeContours.get(i).toArray()), contoursPoly[i], 1, true);
+                centers[i] = new Point();
+                Imgproc.minEnclosingCircle(contoursPoly[i], centers[i], radius[i]);
+
+            }
+            //Draw circle for each large contour
+            for (int i = 0; i < largeContours.size(); i++) {
+                Imgproc.circle(circleOutput, centers[i], (int) radius[i][0],new Scalar(255, 0, 0), 1);
+            }
+            //imageViewer("82 Circles found", circleOutput);
+
+            //********************************************************************************
+            //Centroids - Everything must be to scale
+            //********************************************************************************
+
+            ArrayList<Moments> mu = new ArrayList<Moments>(largeContours.size());
+            Mat centreOutput = Mat.zeros(largeContoursFound.size(), CvType.CV_8UC3);
+            for (int i = 0; i < largeContours.size(); i++) {
+                mu.add(i, Imgproc.moments(largeContours.get(i), false));
+                Moments p = mu.get(i);
+                int x = (int) (p.get_m10() / p.get_m00());
+                int y = (int) (p.get_m01() / p.get_m00());
+                Imgproc.circle(centreOutput, new Point(x, y), 4, new Scalar(255, 255, 255), 30);
+            }
+            //imageViewer("83 Centres found", centreOutput);
+
+
+            //***********************************************
+            //PostProcessing - Morphology Classifier
+            //  Use dilation to "Connect the dots"
+            //  Testing showed the centroids were clustered together
+            //  Then use area or perimeter as a classifier filter
+            //***********************************************
+
+            Mat postDilate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(150,15));
+            Imgproc.dilate(centreOutput,centreOutput,postDilate);
+            //imageViewer("91 PostDilated", centreOutput);
+
+            Mat postClose = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,4)); //4,4
+            Imgproc.morphologyEx(centreOutput, centreOutput, Imgproc.MORPH_CLOSE, postClose);
+            //imageViewer("92 PostClose", centreOutput);
+
+            Mat postDenoize = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(100,100));
+            Imgproc.morphologyEx(centreOutput,centreOutput, Imgproc.MORPH_OPEN, postDenoize);
+            //imageViewer("93 PostDenoize", centreOutput);
+
+            //Mat postOutline = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(50,50));
+            //Imgproc.morphologyEx(centreOutput, centreOutput, Imgproc.MORPH_GRADIENT, postOutline);
+
+            //Find area
+            Mat centreOutputGrey = new Mat();
+            Imgproc.cvtColor(centreOutput, centreOutputGrey, Imgproc.COLOR_RGB2GRAY);
+            Imgproc.findContours(centreOutputGrey, postContours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
+
+            for (int i = 0; i < postContours.size(); i++) {
+                double area = Imgproc.contourArea(postContours.get(i));
+                if(area > THRESHOLD_AREA_SIZE) {
+                    System.out.println("POST AREA: " + area + "AREA COUNTER: " + areaCounter);
+                    //Imgproc.drawContours(postContoursFound, postContours, i, new Scalar(0, 255, 0), FILLED);
+                    areaCounter++;
+                }
+            }
+
+            //imageViewer("93 PostEND", postContoursFound);
+
+            //Calculates if sheet music or not
+            if(areaCounter >= THRESHOLD_AREA_COUNT){
+                returnVariables = new Pair(true, areaCounter);
+                //returnVariables.setBoolean(true);
+                //returnVariables.setInteger(areaCounter);
+                System.out.println("TEST RETURN VARIABLES: "+ returnVariables.toString());
+            }
+
+        }
+        catch(Exception e){
+            System.err.println(e);
+        }
+        return returnVariables;
+    }
     //******************
     //CLASSIFIER FUNCTIONS
