public void TestSizeImageSwap() { Bitmap imgOrigin = Resource1.testBeforeFilter; Bitmap imgResult = ExtBitmap.SwapFilter(imgOrigin); Assert.AreEqual(imgOrigin.Size, imgResult.Size); }
public void extensionTest() { Bitmap imageFiltreeTest = ExtBitmap.Laplacian5x5Filter(imageInitiale, false); String extensionImageInitiale = Path.GetExtension(imageInitiale.ToString()); String extensionImageFiltree = Path.GetExtension(imageFiltreeTest.ToString()); Assert.AreEqual(extensionImageInitiale, extensionImageFiltree); }
private static Bitmap ConvertirParaProcesar(Bitmap original) { Bitmap resultado = Grayscale.CommonAlgorithms.BT709.Apply(ExtBitmap.Laplacian3x3Filter(original, true)); original.Dispose(); resultado.Save("Convertida" + DateTime.Now.Millisecond + ".bmp"); return(resultado); }
public void TestPrewittFilter() { Bitmap or = GetImage.GetOriginalBitmap(); Bitmap whawewant = GetImage.GetBitmapFromFile("Prewitt.jpg"); Bitmap filtered = ExtBitmap.PrewittFilter(or, false); Assert.IsTrue(GetImage.Equals(filtered, whawewant)); }
public void TestLaplacian_5x5() { Bitmap or = GetImage.GetOriginalBitmap(); Bitmap whawewant = GetImage.GetBitmapFromFile("Laplacian_5x5.jpg"); Bitmap filtered = ExtBitmap.Laplacian5x5Filter(or, false); Assert.IsTrue(GetImage.Equals(filtered, whawewant)); }
public void TestKirschFilterGrayScale() { Bitmap or = GetImage.GetOriginalBitmap(); Bitmap whawewant_but_in_gray = GetImage.GetBitmapFromFile("KirschGrayscale.jpg"); Bitmap filtered_but_in_gray = ExtBitmap.KirschFilter(or, true); Assert.IsTrue(GetImage.Equals(filtered_but_in_gray, whawewant_but_in_gray)); }
public void pixelIntegrityTest() { Bitmap imageFiltree = ExtBitmap.Laplacian5x5Filter(imageInitiale, false); for (int x = 0; x < imageFiltree.Height; x++) { for (int y = 0; y < imageFiltree.Width; y++) { Assert.AreEqual(imageFiltreeLaplacian.GetPixel(y, x), imageFiltree.GetPixel(y, x)); } } }
public void ExtBitmapCopyToSquareCanvasTest() { // get the class through interface IBitmap bitmap = new ExtBitmap(); // get an image and set a canvas width Bitmap originalBitmap = Properties.Resources.panda; int canvasWidth = 559; // run the method to copy the image to the suqare canvas bitmap.CopyToSquareCanvas(originalBitmap, canvasWidth); Assert.IsTrue(true); }
public void colorPixelTest() { Bitmap imageFiltreeTest = ExtBitmap.Laplacian5x5Filter(imageInitiale, false); for (int i = 0; i < imageFiltreeTest.Width; i++) { for (int j = 0; j < imageFiltreeTest.Height; j++) { Color couleurPixelSouhaite = imageFiltreeLaplacian.GetPixel(i, j); Color couleurPixelTest = imageFiltreeTest.GetPixel(i, j); Assert.AreEqual(couleurPixelSouhaite, couleurPixelTest); } } }
//Tests that the image output corresponds to what is expected in terms of color by testing all the pixels public void TestColorPixelSobel() { Bitmap imgTest = Resource1.InTheArmySobel; Bitmap imgResult = ExtBitmap.Sobel3x3Filter(Resource1.InTheArmyOriginal, false); for (int i = 0; i < imgTest.Width; i++) { for (int j = 0; j < imgTest.Height; j++) { Color pixelRef = imgTest.GetPixel(i, j); Color pixelRes = imgResult.GetPixel(i, j); Assert.AreEqual(pixelRef, pixelRes); } } }
public void TestRainbowFilter() { //get images from Resources Bitmap testImage = Properties.Resources.original_wide; Bitmap realResult = Properties.Resources.original_wide_rainbow; //apply filter on test image Bitmap result = ExtBitmap.ApplyRainbowFilter(testImage); //get Hash from images string resultImageHash = TestFunctions.GetImageHash(result); string realResultImageHash = TestFunctions.GetImageHash(realResult); //comparison Assert.AreEqual(resultImageHash, realResultImageHash); }
//Tests that the image output corresponds to what is expected in terms of color by testing all the pixels public void TestColorPixelSwap() { Bitmap imgTest = Resource1.filterTest; Bitmap imgResult = ExtBitmap.SwapFilter(Resource1.testBeforeFilter); for (int i = 0; i < imgTest.Width; i++) { for (int j = 0; j < imgTest.Height; j++) { Color pixelRef = imgTest.GetPixel(i, j); Color pixelRes = imgResult.GetPixel(i, j); Assert.AreEqual(pixelRef, pixelRes); } } }
public void TestPrewitt() { //get images from Resources Bitmap testImage = Properties.Resources.original; Bitmap realResult = Properties.Resources.original_prewitt; //apply filter on test image Bitmap result = ExtBitmap.PrewittFilter(testImage, false); //get Hash from images string resultImageHash = TestFunctions.GetImageHash(result); string realResultImageHash = TestFunctions.GetImageHash(realResult); //comparison Assert.AreEqual(resultImageHash, realResultImageHash); }
// Return a bitmap with the Prewitt edge applied on it public Bitmap PrewittEdge(Bitmap selectedSource, bool grayscale = true) { try { // Apply the Prewitt edge on the bitmap with selectedSource in parameter // And store the result in resultBitmap Bitmap resultBitmap = ExtBitmap.ConvolutionEdge(selectedSource, GetPrewitt3x3Horizontal(), GetPrewitt3x3Vertical(), 1.0, 0, grayscale); // return the resultBitmap return(resultBitmap); } catch (Exception e) { // If there is an exception catch it and return null Console.WriteLine("Image is null"); Console.WriteLine(e.Message); return(null); } }
public void TestImageLaplacian3x3() { Bitmap testedBitmap; //Resize with the size of canvas testedBitmap = ExtBitmap.CopyToSquareCanvas(originalBitmapTest, 600); //send a photo to modify it testedBitmap = ExtBitmap.Laplacian3x3Filter(testedBitmap, false); //Retrieve the already modified photo Bitmap testBitmap = null; string FileName = @"C:\Users\quent\Documents\GitHub\Image_Filtering_Detection\UnitTestImageDection\Laplacian3x3.png"; StreamReader streamReader = new StreamReader(FileName); testBitmap = (Bitmap)Bitmap.FromStream(streamReader.BaseStream); streamReader.Close(); //comparison Assert.AreEqual(testBitmap.GetPixel(2, 2), testedBitmap.GetPixel(2, 2)); }
public void TestImageWidthInforiorToMatrixShouldNotEnterForLoopsModifyingTheImage() { //Bitmap for testing Bitmap testBitmap = new Bitmap(1, 1); //Bitmap sent to Edge Filter Bitmap receivedAfterTest = ExtBitmap.Laplacian3x3Filter(testBitmap, false); //Lock bytes of image for creating a byter array buffer BitmapData sourceData = testBitmap.LockBits(new Rectangle(0, 0, testBitmap.Width, testBitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); //Create 2 byte arrays with full image dimensions (height x width (number of byter for first pixel line) byte[] pixelBuffer = new byte[sourceData.Stride * sourceData.Height]; byte[] resultBuffer = new byte[sourceData.Stride * sourceData.Height]; //Copy byte of image to byte array Marshal.Copy(sourceData.Scan0, pixelBuffer, 0, pixelBuffer.Length); //Unlock bytes image testBitmap.UnlockBits(sourceData); //Craete the testing result Bitmap Bitmap resultTestBitmap = new Bitmap(testBitmap.Width, testBitmap.Height); //Lock byte for copying bytes BitmapData resultData = resultTestBitmap.LockBits(new Rectangle(0, 0, resultTestBitmap.Width, resultTestBitmap.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); //Copy byte array to data Marshal.Copy(resultBuffer, 0, resultData.Scan0, resultBuffer.Length); //Unlock bits for bitmap resultTestBitmap.UnlockBits(resultData); //Compare single pixel Assert.AreEqual(resultTestBitmap.GetPixel(0, 0), receivedAfterTest.GetPixel(0, 0)); }
public void TestLaplacian3x3() { // Definition of start image and control image Bitmap startPicture = Properties.Resources.firefox; Bitmap controlPicture = Properties.Resources.firefox_filtered; // Instanciation of a ExtBitmap ExtBitmap eb = new ExtBitmap(); // Execution of the method Bitmap resultPicture = eb.Laplacian3x3Filter(startPicture); // Test the size of result image Assert.AreEqual(resultPicture.Size, startPicture.Size); // Control each pixel for (int i = 0; i < controlPicture.Width; i++) { for (int j = 0; j < controlPicture.Height; j++) { Assert.AreEqual(resultPicture.GetPixel(i, j), controlPicture.GetPixel(i, j)); } } }
public void TestCopyToSquareCanvasWithSamllerCanvas() { //Initialize sizes float bpmHeight = 200f; float bpmWidth = 200f; int canvasSize = 100; //Determine the ratio for expected results float ratio = bpmWidth / canvasSize; //Send bitmap with height, width and canvas to tested method Bitmap bpmAfterMethodCanvas = ExtBitmap.CopyToSquareCanvas(new Bitmap((int)bpmWidth, (int)bpmHeight), canvasSize); //All expected sizes float bpmWidthExpected = canvasSize; float bpmHeightExpected = bpmHeight / ratio; //Tested sizes float widthResult = (float)bpmAfterMethodCanvas.Width; float heigthResult = (float)bpmAfterMethodCanvas.Height; //Compare values Assert.AreEqual(bpmWidthExpected, widthResult); Assert.AreEqual(bpmHeightExpected, heigthResult); }
public override Bitmap Apply(Bitmap bitmap) { return(ExtBitmap.PrewittFilter(bitmap, true)); }
public override Bitmap Apply(Bitmap bitmap) { return(ExtBitmap.LaplacianOfGaussianFilter(bitmap)); }
public override Bitmap Apply(Bitmap bitmap) { return(ExtBitmap.KirschFilter(bitmap, true)); }
//Tests that the method returns null if a null image is used public void TestEmptyImageKirsch() { Bitmap imgNull = null; Assert.IsNull(ExtBitmap.KirschFilter(imgNull)); }
//Tests that the method returns null if a null image is used public void TestEmptyImageSobel() { Bitmap imgNull = null; Assert.IsNull(ExtBitmap.Sobel3x3Filter(imgNull)); }
public override Bitmap Apply(Bitmap bitmap) { return(ExtBitmap.Laplacian3x3Filter(bitmap, true)); }
public override Bitmap Apply(Bitmap bitmap) { return(ExtBitmap.Sobel3x3Filter(bitmap, true)); }
public override Bitmap Apply(Bitmap bitmap) { return(ExtBitmap.Laplacian3x3OfGaussian5x5Filter1(bitmap)); }
public override Bitmap Apply(Bitmap bitmap) { return(ExtBitmap.Laplacian5x5Filter(bitmap, false)); }
//Tests that the method returns null if a null image is used public void TestEmptyImageSwap() { Bitmap imgNull = null; Assert.IsNull(ExtBitmap.SwapFilter(imgNull)); }
public void sizeTest() { Bitmap imageFiltree = ExtBitmap.Laplacian5x5Filter(imageInitiale); Assert.AreEqual(imageInitiale.Size, imageFiltree.Size); }