public Form1() { InitializeComponent(); photo = new DirectBitmap(GK3.Properties.Resources.Lenna); orginalPicture = new DirectBitmap(GK3.Properties.Resources.Lenna); transformedPicture = new DirectBitmap(GK3.Properties.Resources.Lenna); ownFunctionPicture = new DirectBitmap(300, 300); pictureBox.Image = photo.Bitmap; pictureBoxOwnFunction.Image = ownFunctionPicture.Bitmap; polygons = new List <Polygon>(); isPolygonCreating = false; isDrawing = false; ownFunction = new Vertex[OWN_FUNCTION_POINTS]; FillFunction(ownFunction); setMode(ModeType.AddPolygon); filterType = FilterType.NoFilter; filter = new NegationFilter(); brightnessFilter = new BrightnessChangeFilter(); contrastFilter = new ContrastFilter(); gammaFilter = new GammaCorrectionFilter(); ownFunctionFilter = new OwnFunctionFilter(ownFunction); filter.setNext(brightnessFilter); brightnessFilter.setNext(contrastFilter); contrastFilter.setNext(gammaFilter); gammaFilter.setNext(ownFunctionFilter); histR.Series[0].Color = Color.Red; histG.Series[0].Color = Color.Green; histB.Series[0].Color = Color.Blue; DrawOwnFunctionAxis(); DrawOwnFunction(); UpdatePhoto(); }
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(); } }