private static void ShowProjections(Graph graph, ComparableImage comparable) { graph.ClearCurves(); graph.AddPlotCurve(Color.Red, comparable.Projections.HorizontalProjection); graph.AddPlotCurve(Color.Green, comparable.Projections.VerticalProjection); graph.Invalidate(); }
public static void IsSameLooking(FileInfo expSlideImage, FileInfo actualSlideImage, double similarityTolerance = 0.95) { ComparableImage actualSlideInPic = new ComparableImage(actualSlideImage); ComparableImage expSlideInPic = new ComparableImage(expSlideImage); double similarity = actualSlideInPic.CalculateSimilarity(expSlideInPic); Assert.IsTrue(similarity > similarityTolerance, "The slides look different. Similarity = " + similarity); }
public static void IsSameLooking(FileInfo expSlideImage, FileInfo actualSlideImage) { var actualSlideInPic = new ComparableImage(actualSlideImage); var expSlideInPic = new ComparableImage(expSlideImage); var similarity = actualSlideInPic.CalculateSimilarity(expSlideInPic); Assert.IsTrue(similarity > 0.95, "The slides look different. Similarity = " + similarity); }
// compare shape's prop & looking // // You may need to call PpOperations.ExportSelectedShapes() // to get FileInfo of the exported shape in pic public static void IsSameLooking(Shape expShape, FileInfo expFileInfo, Shape actualShape, FileInfo actualFileInfo) { IsSameShape(expShape, actualShape); var actualShapeInPic = new ComparableImage(actualFileInfo); var expShapeInPic = new ComparableImage(expFileInfo); var similarity = actualShapeInPic.CalculateSimilarity(expShapeInPic); Assert.IsTrue(similarity > 0.95, "The shapes look different. Similarity = " + similarity); }
public static Boolean ImageSimilarity(string image1, string image2) { ImgSimilarityRate = SharedResources.GetResource().ImgSimilarityRate; if (image1 != null && image2 != null) { var f1 = new ComparableImage(new FileInfo(image1)); var f2 = new ComparableImage(new FileInfo(image2)); /* Calculate Image Similarity */ var sim = f1.CalculateSimilarity(f2); /* Show Hash in TextBoxes */ return(sim * 100 > Convert.ToInt32(ImgSimilarityRate)); } return(false); }
private void ProcessImages(FileInfo[] files) { var comparableImages = new List <ComparableImage>(); var index = 0x0; var operationStartTime = DateTime.Now; foreach (var file in files) { var comparableImage = new ComparableImage(file); comparableImages.Add(comparableImage); index++; Invoke(updateOperationStatusDelegate, new object[] { "Processed images", workingLabel, workingProgressBar, index, operationStartTime }); } Invoke(setMaximumDelegate, new object[] { workingProgressBar, (comparableImages.Count * (comparableImages.Count - 1)) / 2 }); index = 0; var similarityImagesSorted = new List <SimilarityImages>(); operationStartTime = DateTime.Now; for (var i = 0; i < comparableImages.Count - 1; i++) { for (var j = i + 1; j < comparableImages.Count; j++) { var source = comparableImages[i]; var destination = comparableImages[j]; var similarity = source.CalculateSimilarity(destination); var sim = new SimilarityImages(source, destination, similarity); similarityImagesSorted.Add(sim); index++; Invoke(updateOperationStatusDelegate, new object[] { "Compared images", workingLabel, workingProgressBar, index, operationStartTime }); } } similarityImagesSorted.Sort(); similarityImagesSorted.Reverse(); similarityImages = new BindingList <SimilarityImages>(similarityImagesSorted); BeginInvoke(updateDataGridViewDelegate, new object[] { similarityImages, imagesDataGridView }); }
public double CalculateSimilarity() { double similarity = 0.0; if (Source.IsNotNull() && Target.IsNotNull()) { ComparableImage pc = new ComparableImage(new FileInfo(Source.Path)); ComparableImage cc = new ComparableImage(new FileInfo(Target.Path)); similarity = pc.CalculateSimilarity(cc); } //if (OnCalculateComplete.IsNotNull()) //OnCalculateComplete.Invoke(); return(similarity); }
public static bool ThisScreenPresent(string folder, string thisPath, IntPtr emuHandle, Rectangle bounder, double similarity = 0.8) { SaveScreenAs(folder, ActualScreenPath, emuHandle, bounder); string FullActual = ProperFolder(folder) + ProperName(ActualScreenPath); string FullThis = ProperFolder(folder) + ProperName(thisPath); try { ComparableImage actualScreen = new ComparableImage(new FileInfo(FullActual)); ComparableImage thisScreen = new ComparableImage(new FileInfo(FullThis)); if (thisScreen.CalculateSimilarity(actualScreen) > similarity) { return(true); } } catch (Exception e) { } return(false); }
static void Main(string[] args) { ScreenCapture sc = new ScreenCapture(); var im = sc.CaptureScreen(); im.Save("test.png"); ComparableImage imag1 = new ComparableImage(new FileInfo(@"C:\Users\liel_r\Downloads\Runtime - 10022007\img1.png")); ComparableImage imag2 = new ComparableImage(new FileInfo(@"C:\Users\liel_r\Downloads\Runtime - 10022007\img2.png")); ComparableImage imag3 = new ComparableImage(new FileInfo(@"C:\Users\liel_r\Downloads\Runtime - 10022007\img3.png")); var sim = imag1.CalculateSimilarity(imag2); Console.WriteLine("imag1 sim to imag2 by -" + sim * 100 + "%"); var sim2 = imag1.CalculateSimilarity(imag3); Console.WriteLine("imag1 sim to imag3 by -" + sim2 * 100 + "%"); }
// For clarity, we are also setting a picture box image // from the ComparableImage when it is assigned: private void SetImage(ComparableImage image) { this.image = image; pictureBox.Image = image.Image; }
public static double getBitmapSimilarity(Bitmap a, Bitmap b) { ComparableImage a1 = new ComparableImage(a), b1 = new ComparableImage(b); return(a1.CalculateSimilarity(b1)); }