private void loadButtonClick(object sender, RoutedEventArgs e) { // Configure open file dialog box Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "Document"; // Default file name dlg.DefaultExt = ".jpg"; // Default file extension dlg.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png"; // Show open file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { // Open document string filename = dlg.FileName; Bitmap image = new Bitmap(filename); imageHandler = new ImageHandler(image); originalImage.Source = BitmapLoader.loadBitmap(image); filteredImage.Source = BitmapLoader.loadBitmap(image); } }
private void negationButtonClick(object sender, RoutedEventArgs e) { if (imageHandler != null) { // TODO Background worker new Thread(() => { NegationFilter negationFilter = new NegationFilter(); imageHandler.ApplyFilter(image => negationFilter.ApplyFilter(image)); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() => { filteredImage.Source = BitmapLoader.loadBitmap(imageHandler.getFiltered()); })); }).Start(); } }
private void thresholdingButtonClick(object sender, RoutedEventArgs e) { if (imageHandler != null) { // TODO Background worker new Thread(() => { int threshhold = 170; Thresholding threshHolder = new Thresholding(threshhold); Bitmap filtered = threshHolder.ApplyDithering(imageHandler.getOriginal()); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() => { filteredImage.Source = BitmapLoader.loadBitmap(filtered); })); }).Start(); } }
private void medianCutClick(object sender, RoutedEventArgs e) { if (imageHandler != null) { // TODO Background worker new Thread(() => { int k = 2; MedianCut medianCut = new MedianCut(imageHandler.getOriginal()); medianCut.Compute(k); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() => { filteredImage.Source = BitmapLoader.loadBitmap(medianCut.Image); })); Console.Write("Median Cut finished \n"); }).Start(); } }
private void averageDitherButtonClick(object sender, RoutedEventArgs e) { if (imageHandler != null) { // TODO Background worker new Thread(() => { int k = 2; AverageDither dither = new AverageDither(k); Bitmap filtered = dither.ApplyDithering(imageHandler.getOriginal()); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() => { filteredImage.Source = BitmapLoader.loadBitmap(filtered); })); Console.Write("Median Cut finished \n"); }).Start(); } }
private void gammaCorrectionButtonClick(object sender, RoutedEventArgs e) { if (imageHandler != null) { // TODO Background worker new Thread(() => { double gamma = 1; this.Dispatcher.Invoke((Action)(() => { gamma = Convert.ToDouble(gammaTextBox.Text); })); GammaCorrectionFilter filter = new GammaCorrectionFilter(gamma, 1); imageHandler.ApplyFilter(image => filter.ApplyFilter(image)); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() => { filteredImage.Source = BitmapLoader.loadBitmap(imageHandler.getFiltered()); })); }).Start(); } }