updated test
authorgit <wangtsaichang@gmail.com>
Thu, 29 Jun 2017 10:16:42 +0000 (12:16 +0200)
committergit <wangtsaichang@gmail.com>
Thu, 29 Jun 2017 10:16:42 +0000 (12:16 +0200)
Conversion_CYC/TestColor.java

index 8a6e7d0..7f1fbe6 100644 (file)
@@ -19,6 +19,7 @@ public class TestColor {
 
        BufferedImage  input_image;
        BufferedImage  output_image;
+       BufferedImage  output_image_gray;
        BufferedImage  image;
        int width;
        int height;
@@ -27,9 +28,7 @@ public class TestColor {
        public void setUp() throws Exception {
                LoadFile file = new LoadFile();
                input_image     = file.Load_File("test.jpg");
-       
-               BlackandWhite bw_image = new BlackandWhite();
-       output_image = bw_image.Black_and_White(input_image);
+
        }
 
        /**
@@ -41,7 +40,9 @@ public class TestColor {
 
        @Test
        public void testBlackandWhite() {
-               
+               BlackandWhite bw_image = new BlackandWhite();
+       output_image = bw_image.Black_and_White(input_image);
+       
                try {
         
                 width = output_image.getWidth();
@@ -65,5 +66,30 @@ public class TestColor {
              } catch (Exception e) {}
                
        }
-
+       @Test
+       public void testGray() {
+               GrayScale g_image = new GrayScale();
+       output_image_gray = g_image.Gray_Scale(input_image);
+               try {
+        
+                width = output_image_gray.getWidth();
+                height = output_image_gray.getHeight();
+                
+                for(int i=0; i<height; i++){
+                
+                   for(int j=0; j<width; j++){
+                   
+                      Color c = new Color(output_image_gray.getRGB(j, i));
+                      
+                      int red = (int)c.getRed();
+                      int green = (int)c.getGreen();
+                      int blue = (int)c.getBlue();
+                    
+                      assertTrue((red==green)&&(red==blue));
+                  
+                   }
+                }  
+             } catch (Exception e) {}
+               
+       }
 }