BufferedImage input_image;
BufferedImage output_image;
+ BufferedImage output_image_gray;
BufferedImage image;
int width;
int height;
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);
+
}
/**
@Test
public void testBlackandWhite() {
-
+ BlackandWhite bw_image = new BlackandWhite();
+ output_image = bw_image.Black_and_White(input_image);
+
try {
width = output_image.getWidth();
} 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) {}
+
+ }
}