private void ProcessImages(DataTable dt) { var comparableImages = new List <ComparableImage>(); //Invoke(setMaximumDelegate, new object[] { workingProgressBar, files.Length }); var index = 0x0; var operationStartTime = DateTime.Now; int k = Application.StartupPath.IndexOf("\\bin"); string sub = Application.StartupPath.Substring(k); string ImagePath = Application.StartupPath.Substring(0, Application.StartupPath.Length - sub.Length); foreach (DataRow row in dt.Rows) { var comparableImage = new ComparableImage(new FileInfo(ImagePath + row["Url"].ToString())); 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; double maxSimilarity = 0; for (var i = 0; i < comparableImages.Count; i++) { if (exit) { return; } ComparableImage sourceImage = new ComparableImage(new FileInfo(ImageName)); var destination = comparableImages[i]; var similarity = sourceImage.CalculateSimilarity(destination); var sim = new SimilarityImages(sourceImage, destination, similarity); if (sim.Similarity >= double.Parse(txtPrecision.Value.ToString())) { if (maxSimilarity < sim.Similarity) { maxSimilarity = sim.Similarity; } similarityImagesSorted.Add(sim); index++; } } similarityImagesSorted.Sort(); similarityImagesSorted.Reverse(); similarityImages = new BindingList <SimilarityImages>(similarityImagesSorted); BeginInvoke(updateListViewDelegate, new object[] { similarityImages, lvImageSimilar }); }
/// <summary> /// Calculate the similarity to another image. /// </summary> /// <param name="compare">The image to compare with.</param> /// <returns>Return a value from 0 to 1 that is the similarity.</returns> public double CalculateSimilarity(ComparableImage compare) { return(projections.CalculateSimilarity(compare.projections)); }
public SimilarityImages(ComparableImage source, ComparableImage destination, double similarity) { this.source = source; this.destination = destination; this.similarity = similarity; }
/// <summary> /// Calculate the similarity to another image. /// </summary> /// <param name="compare">The image to compare with.</param> /// <returns>Return a value from 0 to 1 that is the similarity.</returns> public double CalculateSimilarity(ComparableImage compare) { return projections.CalculateSimilarity(compare.projections); }
private void ProcessImages(DataTable dt) { var comparableImages = new List<ComparableImage>(); //Invoke(setMaximumDelegate, new object[] { workingProgressBar, files.Length }); var index = 0x0; var operationStartTime = DateTime.Now; int k = Application.StartupPath.IndexOf("\\bin"); string sub = Application.StartupPath.Substring(k); string ImagePath = Application.StartupPath.Substring(0, Application.StartupPath.Length - sub.Length) ; foreach (DataRow row in dt.Rows) { var comparableImage = new ComparableImage(new FileInfo(ImagePath+row["Url"].ToString())); 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; double maxSimilarity = 0; for (var i = 0; i < comparableImages.Count; i++) { if (exit) { return; } ComparableImage sourceImage = new ComparableImage(new FileInfo(ImageName)); var destination = comparableImages[i]; var similarity = sourceImage.CalculateSimilarity(destination); var sim = new SimilarityImages(sourceImage, destination, similarity); if (sim.Similarity>=double.Parse(txtPrecision.Value.ToString())) { if (maxSimilarity < sim.Similarity) maxSimilarity = sim.Similarity; similarityImagesSorted.Add(sim); index++; } } similarityImagesSorted.Sort(); similarityImagesSorted.Reverse(); similarityImages = new BindingList<SimilarityImages>(similarityImagesSorted); BeginInvoke(updateListViewDelegate, new object[] { similarityImages, lvImageSimilar }); }