public void FilterTestBlackAndWhite() { //load the original bitmap bitmapOriginal = ImageUtils.loadOriginalPicture(); //apply Image Filter filter Bitmap bitmapOriginalWithImageFilters = ImageFilters.BlackWhite(bitmapOriginal); //apply manually filter on the bitmap expected Bitmap bitmapExpected = bitmapOriginal; int rgb; Color c; for (int y = 0; y < bitmapExpected.Height; y++) { for (int x = 0; x < bitmapExpected.Width; x++) { c = bitmapExpected.GetPixel(x, y); rgb = (int)((c.R + c.G + c.B) / 3); bitmapExpected.SetPixel(x, y, Color.FromArgb(rgb, rgb, rgb)); } } //check if the pixel of the two images are the same bool result = ImageUtils.comparePixelImages(bitmapOriginalWithImageFilters, bitmapExpected); Assert.IsTrue(result); }
public void extensionTest() { Bitmap imageFiltreeTest = ImageFilters.BlackWhite(imageInitiale); String extensionImageInitiale = Path.GetExtension(imageInitiale.ToString()); String extensionImageFiltree = Path.GetExtension(imageFiltreeTest.ToString()); Assert.AreEqual(extensionImageInitiale, extensionImageFiltree); }
public void pixelIntegrityTest() { Bitmap imageFiltree = ImageFilters.BlackWhite(imageInitiale); for (int x = 0; x < imageFiltree.Height; x++) { for (int y = 0; y < imageFiltree.Width; y++) { Assert.AreEqual(imageInitiale.GetPixel(y, x), imageFiltree.GetPixel(y, x)); } } }
public void colorPixelTest() { Bitmap imageFiltreeTest = ImageFilters.BlackWhite(imageInitiale); for (int i = 0; i < imageFiltreeTest.Width; i++) { for (int j = 0; j < imageFiltreeTest.Height; j++) { Color couleurPixelSouhaite = imageFiltreeBlackWhite.GetPixel(i, j); Color couleurPixelTest = imageFiltreeTest.GetPixel(i, j); Assert.AreEqual(couleurPixelSouhaite, couleurPixelTest); } } }
public void BlackWhiteTest() { // Custom image used for test Bitmap TestImg = new Bitmap(100, 100); // Method result for comparison Bitmap Result; for (int y = 0; y < TestImg.Height; y++) { for (int x = 0; x < TestImg.Width; x++) { TestImg.SetPixel(x, y, Color.FromArgb(120, 90, 150)); } } Result = ImageFilters.BlackWhite(TestImg); Assert.IsTrue(IsPixelColorEqual(Result)); }
public void sizeTest() { Bitmap imageFiltree = ImageFilters.BlackWhite(imageInitiale); Assert.AreEqual(imageInitiale.Size, imageFiltree.Size); }
public override Bitmap Apply(Bitmap bitmap) { return(ImageFilters.BlackWhite(new Bitmap(bitmap))); }