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 33417)
+++ /other-projects/is-sheet-music-encore/trunk/image-identification-dev-02/.idea/workspace.xml	(revision 33418)
@@ -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="2394">
-              <caret line="780" selection-start-line="780" selection-end-line="780" />
+            <state relative-caret-position="2774">
+              <caret line="800" column="12" selection-start-line="800" selection-start-column="12" selection-end-line="800" selection-end-column="92" />
               <folding>
                 <element signature="imports" expanded="true" />
@@ -40,9 +40,9 @@
         <entry file="file://$PROJECT_DIR$/image-identification-development/src/MainMorph.java">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="340">
-              <caret line="275" lean-forward="true" selection-start-line="275" selection-end-line="275" />
+            <state relative-caret-position="347">
+              <caret line="306" column="41" selection-start-line="306" selection-start-column="41" selection-end-line="306" selection-end-column="41" />
               <folding>
-                <element signature="class#StartAndEndPoint#0;class#MainMor#0" />
-                <element signature="method#toBufferedImage#0;class#MainMor#0" />
+                <element signature="e#9745#9798#1" />
+                <element signature="e#10939#13586#1" />
               </folding>
             </state>
@@ -156,5 +156,5 @@
       <window_info anchor="bottom" id="Messages" order="10" weight="0.32962137" />
       <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
-      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
+      <window_info anchor="right" id="Ant Build" order="1" weight="0.24952137" />
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
       <window_info anchor="right" id="Palette" order="3" />
@@ -162,4 +162,8 @@
       <window_info anchor="right" id="Maven" order="5" weight="0.3299298" />
     </layout>
+  </component>
+  <component name="antWorkspaceConfiguration">
+    <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
+    <option name="FILTER_TARGETS" value="false" />
   </component>
   <component name="editorHistoryManager">
@@ -206,6 +210,6 @@
     <entry file="file://$PROJECT_DIR$/image-identification-development/src/Main.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="2394">
-          <caret line="780" selection-start-line="780" selection-end-line="780" />
+        <state relative-caret-position="2774">
+          <caret line="800" column="12" selection-start-line="800" selection-start-column="12" selection-end-line="800" selection-end-column="92" />
           <folding>
             <element signature="imports" expanded="true" />
@@ -229,9 +233,9 @@
     <entry file="file://$PROJECT_DIR$/image-identification-development/src/MainMorph.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="340">
-          <caret line="275" lean-forward="true" selection-start-line="275" selection-end-line="275" />
+        <state relative-caret-position="347">
+          <caret line="306" column="41" selection-start-line="306" selection-start-column="41" selection-end-line="306" selection-end-column="41" />
           <folding>
-            <element signature="class#StartAndEndPoint#0;class#MainMor#0" />
-            <element signature="method#toBufferedImage#0;class#MainMor#0" />
+            <element signature="e#9745#9798#1" />
+            <element signature="e#10939#13586#1" />
           </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 33417)
+++ /other-projects/is-sheet-music-encore/trunk/image-identification-dev-02/image-identification-development/src/MainMorph.java	(revision 33418)
@@ -177,4 +177,5 @@
 
             //Variables
+            int codeVersion = 2;
             Mat edgesDetected = new Mat();
             Mat mid = new Mat();
@@ -222,56 +223,145 @@
             //****************MORPHOLOGY****************************************************************************************
 
-            //Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(4,8));
-            //Imgproc.morphologyEx(original, mid, Imgproc.MORPH_OPEN, kernel);
-            //Imgproc.adaptiveThreshold(mid, edgesDetected,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, 2);
-
             // Create the images that will use to extract the horizontal and vertical lines
-            Mat horizontal = original.clone();
-            Mat vertical = original.clone();
-            // Specify size on horizontal axis
-            int horizontal_size = horizontal.cols() / 30;
-            // Create structure element for extracting horizontal lines through morphology operations
-            Mat horizontalStructure = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(horizontal_size,1));
-            // Apply morphology operations
-            Imgproc.erode(horizontal, horizontal, horizontalStructure);
-            Imgproc.dilate(horizontal, horizontal, horizontalStructure);
-            // Show extracted horizontal lines
-            showWaitDestroy("horizontal" , horizontal);
-            // Specify size on vertical axis
-            int vertical_size = vertical.rows() / 30;
-            // Create structure element for extracting vertical lines through morphology operations
-            Mat verticalStructure = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size( 1,vertical_size));
-            // Apply morphology operations
-            Imgproc.erode(vertical, vertical, verticalStructure);
-            Imgproc.dilate(vertical, vertical, verticalStructure);
-            // Show extracted vertical lines
-            showWaitDestroy("vertical", vertical);
-            // Inverse vertical image
-            Core.bitwise_not(vertical, vertical);
-            showWaitDestroy("vertical_bit" , vertical);
-            // Extract edges and smooth image according to the logic
-            // 1. extract edges
-            // 2. dilate(edges)
-            // 3. src.copyTo(smooth)
-            // 4. blur smooth img
-            // 5. smooth.copyTo(src, edges)
-            // Step 1
-            Mat edges = new Mat();
-            Imgproc.adaptiveThreshold(vertical, edges, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 3, -2);
-            showWaitDestroy("edges", edges);
-            // Step 2
-            Mat kernel = Mat.ones(2, 2, CvType.CV_8UC1);
-            Imgproc.dilate(edges, edges, kernel);
-            showWaitDestroy("dilate", edges);
-            // Step 3
-            Mat smooth = new Mat();
-            vertical.copyTo(smooth);
-            // Step 4
-            Imgproc.blur(smooth, smooth, new Size(2, 2));
-            // Step 5
-            smooth.copyTo(vertical, edges);
-            // Show final result
-            showWaitDestroy("smooth - final", vertical);
-            System.exit(0);
+
+            //dynamic morphology??
+            if(codeVersion == 1) {
+                int hori = original.width();
+                int vert = original.height();
+                //Find ratio between 100 and width and 100 and height
+                int divX = hori/10;
+                int divY = vert/10;
+                int sizeX = (hori/divX) * 10;
+                int sizeY = (vert/divY) * 10;
+
+                Mat test = original.clone();
+                showWaitDestroy("Original", test);
+
+                System.out.println("hori: " + hori + '\t' + "vert: " + vert);
+                System.out.println("sizeX: " + sizeX + '\t' + "sizeY: " + sizeY);
+
+                Mat kernelErode = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(sizeX, (sizeY/100)));
+                Imgproc.erode(test,test,kernelErode);
+                showWaitDestroy("01 Erode", test);
+
+                Mat kernelDialate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(sizeX,(sizeY/10)));
+                Imgproc.dilate(test, test, kernelDialate);
+                showWaitDestroy("02 Dialate", test);
+
+                Mat kernelErodeAgain = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size((sizeX/10),(sizeY/5)));
+                Imgproc.erode(test,test,kernelErodeAgain);
+                showWaitDestroy(" 03 Erode Again", test);
+
+                Mat kernelClose = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size((sizeX/10)*3,(sizeY/10)*3));
+                Imgproc.morphologyEx(test,test,Imgproc.MORPH_CLOSE, kernelClose);
+                showWaitDestroy("04 Close", test);
+
+                Imgproc.adaptiveThreshold(test, test,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C);
+                showWaitDestroy("05 Binarized", test);
+
+                Mat kernelOpen = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size((sizeX/10),(sizeY/20)));
+                Imgproc.morphologyEx(test,test,Imgproc.MORPH_OPEN, kernelOpen);
+                showWaitDestroy(" 06 Open", test);
+
+                Mat kernelDialateAgain = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size((sizeX/5),(sizeY/100)));
+                Imgproc.dilate(test, test, kernelDialateAgain);
+                showWaitDestroy("07 Dialate", test);
+
+
+                Mat kernelCloseAgain = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size((sizeX/10),(sizeY/2)));
+                Imgproc.morphologyEx(test,test,Imgproc.MORPH_CLOSE, kernelCloseAgain);
+                showWaitDestroy(" 08 Close Again (Final)", test);
+            }
+            //Successful hardcode for morhpology
+            if (codeVersion == 2) {
+                Mat test = original.clone();
+                showWaitDestroy("00 Original", test);
+
+                Mat kernelErode = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(100,1));
+                Imgproc.erode(test,test,kernelErode);
+                showWaitDestroy("01 Erode", test);
+
+                Mat kernelDialate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(100,10));
+                Imgproc.dilate(test, test, kernelDialate);
+                showWaitDestroy("02 Dialate", test);
+
+                Mat kernelErodeAgain = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,20));
+                Imgproc.erode(test,test,kernelErodeAgain);
+                showWaitDestroy(" 03 Erode Again", test);
+
+                Mat kernelClose = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(50,30));
+                Imgproc.morphologyEx(test,test,Imgproc.MORPH_CLOSE, kernelClose);
+                showWaitDestroy("04 Close", test);
+
+                Imgproc.adaptiveThreshold(test, test,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV, 15, THRESHOLD_C);
+                showWaitDestroy("05 Binarized", test);
+
+                Mat kernelOpen = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(4,4));
+                Imgproc.morphologyEx(test,test,Imgproc.MORPH_OPEN, kernelOpen);
+                showWaitDestroy(" 06 Open", test);
+
+//                Mat kernelDialateAgain = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(1,10));
+//                Imgproc.dilate(test, test, kernelDialateAgain);
+//                showWaitDestroy("07 Dialate", test);
+
+                //FIGURE OUT FLOOD FILL!!
+                Imgproc.floodFill(test,test, new Point(1,1), new Scalar(2));
+
+
+                Mat kernelCloseAgain = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,50));
+                Imgproc.morphologyEx(test,test,Imgproc.MORPH_CLOSE, kernelCloseAgain);
+                showWaitDestroy(" 08 Close Again (Final)", test);
+
+            }
+            //Tutorial/Demo Code
+            if (codeVersion == 3) {
+                Mat horizontal = original.clone();
+                Mat vertical = original.clone();
+                // Specify size on horizontal axis
+                int horizontal_size = horizontal.cols() / 50;
+                // Create structure element for extracting horizontal lines through morphology operations
+                Mat horizontalStructure = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(horizontal_size, 2));
+                // Apply morphology operations
+                Imgproc.erode(horizontal, horizontal, horizontalStructure);
+                Imgproc.dilate(horizontal, horizontal, horizontalStructure);
+                // Show extracted horizontal lines
+                showWaitDestroy("horizontal", horizontal);
+                // Specify size on vertical axis
+                int vertical_size = vertical.rows() / 30;
+                // Create structure element for extracting vertical lines through morphology operations
+                Mat verticalStructure = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(1, vertical_size));
+                // Apply morphology operations
+                Imgproc.erode(vertical, vertical, verticalStructure);
+                Imgproc.dilate(vertical, vertical, verticalStructure);
+                // Show extracted vertical lines
+                showWaitDestroy("vertical", vertical);
+                // Inverse vertical image
+                Core.bitwise_not(vertical, vertical);
+                showWaitDestroy("vertical_bit", vertical);
+                // Extract edges and smooth image according to the logic
+                // 1. extract edges
+                // 2. dilate(edges)
+                // 3. src.copyTo(smooth)
+                // 4. blur smooth img
+                // 5. smooth.copyTo(src, edges)
+                // Step 1
+                Mat edges = new Mat();
+                Imgproc.adaptiveThreshold(vertical, edges, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 3, -2);
+                showWaitDestroy("edges", edges);
+                // Step 2
+                Mat kernel = Mat.ones(2, 2, CvType.CV_8UC1);
+                Imgproc.dilate(edges, edges, kernel);
+                showWaitDestroy("dilate", edges);
+                // Step 3
+                Mat smooth = new Mat();
+                vertical.copyTo(smooth);
+                // Step 4
+                Imgproc.blur(smooth, smooth, new Size(2, 2));
+                // Step 5
+                smooth.copyTo(vertical, edges);
+                // Show final result
+                showWaitDestroy("smooth - final", vertical);
+                System.exit(0);
+            }
 
 
