private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundHelperRequest argmunets = (BackgroundHelperRequest)e.Argument;
            string imgLocation;
            //AlgorythmParameters parameters = null;

            //Call Algorithm
            Bitmap newImage = new AnaglyphAlgorithmInvoker(argmunets.selectedAlgorythm).Apply(argmunets.image);

            //Save bmp to root of app
            SaveBitmapImage(newImage, argmunets.selectedAlgorythm, out imgLocation);
            var path = System.IO.Path.GetDirectoryName(
                System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);

            string fullpath = path + @"\" + imgLocation;

            BitmapImage bitmap = new BitmapImage();

            bitmap.BeginInit();
            bitmap.UriSource = new Uri(fullpath);
            bitmap.EndInit();

            bitmap.Freeze();
            e.Result = new BackgroundHelperResponse
            {
                image    = bitmap,
                location = fullpath,
            };

            newImage.Dispose();
        }
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundHelperRequest argmunets = (BackgroundHelperRequest)e.Argument;


            //Call Algorithm
            Bitmap newImage = new Fitler().Calc(argmunets.Image);

            e.Result = new BackgroundHelperResponse
            {
                Image    = newImage,
                Location = "",
            };
        }
        private void ColorAnaglyphMenu_Click(dynamic sender, RoutedEventArgs e)
        {
            string selectedAlgorithm = "";

            if (sender.Name == "RegenerateButton")
            {
                selectedAlgorithm = CurrentAlgorythm;
            }
            else
            {
                selectedAlgorithm = sender.Header;
            }
            string imgLocation = "";
            Bitmap imagebmp;

            try
            {
                if (MainImage.Source == null)
                {
                    throw new Exception("Load image first.");
                }

                if (this.CurrentAlgorythm != selectedAlgorithm)
                {
                    AnaglyphParameters.ResetParameters();
                    SetFilterValues();
                    CurrentAlgorythm = selectedAlgorithm;
                }

                imagebmp = new Bitmap((string)MainImageTextBox.Text); // location for image

                BackgroundHelperRequest arguments = new BackgroundHelperRequest()
                {
                    image             = imagebmp,
                    selectedAlgorythm = selectedAlgorithm,
                };

                worker.RunWorkerAsync(argument: arguments);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                MessageBox.Show(exception.Message);
            }
        }
        private void RegenerateButton_Click(object sender, RoutedEventArgs e)
        {
            if (MainImage.Source == null)
            {
                throw new Exception("Load image first.");
            }

            var imagebmp = new Bitmap((string)MainImageTextBox.Text); // location for image

            BackgroundHelperRequest arguments = new BackgroundHelperRequest()
            {
                Image             = imagebmp,
                SelectedAlgorythm = "",
            };

            if (!worker.IsBusy)
            {
                worker.RunWorkerAsync(arguments);
            }
        }