private Bitmap TransformImage(Bitmap scaledImage, Point[] paper) { //Finds width and height of transformation double ratio = ImageManipulation.CalculateRatio(paper, scaledImage.Width, scaledImage.Height); int height = (int)Math.Sqrt(Config.PixelCounts.TransformedImage / ratio); int width = Config.PixelCounts.TransformedImage / height; //Transforms image Bitmap perspectiveImage = scaledImage.PerspectiveTransformImage(paper, width, height); #if DEBUG perspectiveImage.Save(Path.Combine(_workingDirectory, "Debug", "5 Perspective.png"), ImageFormat.Png); #endif return(perspectiveImage); }