static void ProcessTest(string[] args) { switch (args[0]) { case "1": { var iss = new ImageSoftSimilarity(); //foreach (var file in Directory.GetFiles(@"C:\Users\rollrat\Desktop\새 폴더")) // if (file.EndsWith(".png")) // iss.AppendImage(file); Parallel.ForEach(Directory.GetFiles(@"C:\Users\rollrat\Desktop\새 폴더").Where(x => x.EndsWith(".png")), //new ParallelOptions { MaxDegreeOfParallelism = 2 }, (x) => { iss.AppendImage(x); }); //iss.FindForSoft(ImageSoftSimilarity.MakeSoftHash(@"C:\Users\rollrat\Desktop\새 폴더\1577170523.png"), 20); } break; case "2": { var iss = new ImageSoftSimilarity(); Parallel.ForEach(Directory.GetFiles(@"C:\Users\rollrat\Desktop\새 폴더").Where(x => x.EndsWith(".png") || x.EndsWith(".jpg")), //new ParallelOptions { MaxDegreeOfParallelism = 4 }, x => iss.AppendImage(x)); var clustered = iss.Clustering(); } break; } }
static void ProcessSoftClustering(string[] args) { var iss = new ImageSoftSimilarity(); Console.Instance.WriteLine("이미지들을 해싱하는 중..."); using (var progressBar = new Console.ConsoleProgressBar()) { var files = Directory.GetFiles(args[0]).Where(x => x.EndsWith(".png") || x.EndsWith(".jpg") || x.EndsWith(".jpeg") || x.EndsWith(".webp") || x.EndsWith(".bmp")); int counts = files.Count(); int complete = 0; Parallel.ForEach(files, x => { iss.AppendImage(x); progressBar.SetProgress(Interlocked.Increment(ref complete) / (float)counts * 100); }); } List <List <string> > clustered; using (var progressBar = new Console.ConsoleProgressBar()) { Console.Instance.WriteLine("클러스터링 중..."); //clustered = iss.Clustering(x => //{ // progressBar.SetProgress(x.Item1 / (float)x.Item2 * 100); //}); } //clustered.RemoveAll(x => x.Count == 1); //Console.Instance.WriteLine(clustered); }
public ImageSimilarityWindow() { InitializeComponent(); ResultList.DataContext = new ImageSimilarityDataGridViewModel(); ResultList.Sorting += new DataGridSortingEventHandler(new DataGridSorter <ImageSimilarityDataGridItemViewModel>(ResultList).SortHandler); iss = new ImageSoftSimilarity(); }
private void FindPhoto_Click(object sender, RoutedEventArgs e) { double rate; if (!double.TryParse(MaxRate.Text, out rate)) { MessageBox.Show("클러스터링 최고 역치는 실수여야합니다!", "Gallery Explorer", MessageBoxButton.OK, MessageBoxImage.Error); return; } var ofd = new OpenFileDialog(); ofd.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory; ofd.Filter = "이미지 파일 (*.png, *.jpg, *.jpeg, *.bmp, *.webp)|*.png;*.jpg;*.jpeg;*.bmp;*.webp"; if (ofd.ShowDialog() == false) { return; } var hash = ImageSoftSimilarity.MakeSoftHash(ofd.FileName); if (hash == null) { Extends.Post(() => StatusText.Text = $"'{ofd.FileName}'는 지원하는 이미지 파일이 아닌 것 같아요."); return; } var result = iss.FindForSoft(hash, 100).Where(x => x.Item2 <= rate).ToList(); if (result.Count == 0) { Extends.Post(() => StatusText.Text = $"검색 결과가 없습니다 :("); return; } else { Extends.Post(() => StatusText.Text = $"{result.Count}개 항목이 검색되었습니다."); } ImagePanel.Children.Clear(); result.ForEach(x => ImagePanel.Children.Add(new ImageElements(x.Item1, x.Item2))); current = result.Select(x => x.Item1).ToList(); ImagePanel.Children.OfType <ImageElements>().ToList().ForEach(x => x.AdjustWidth((int)WidthSlider.Value)); }