Exemplo n.º 1
0
        private void buttonHDR_Click(object sender, RoutedEventArgs e)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            labelOutput.Content = "";

            OpenFileDialog dialog = new OpenFileDialog
            {
                Filter      = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif) | *.jpg; *.jpeg; *.jpe; *.jfif",
                Title       = "Please select image",
                Multiselect = true
            };

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // Load images
                MyImage[] images = loadImages(dialog.FileNames);

                // Get parameters
                int smoothfactor = (int)getParamater(textboxSmoothFactor);
                int samples      = (int)getParamater(textboxSample);

                // Display images
                drawImages(images);

                // Process images
                HDResult hdrResult = ImageProcessing.HDR(images, smoothfactor, samples);

                // Draw response graphs
                drawReponsesGraph(hdrResult.response);

                // Save HDR image
                HDRImage = hdrResult.HDR;

                MyImage tempImage = HDRImage.ToMyImage();

                // Show HDR image
                processedImage.Source = Utils.getSource(tempImage.GetBitmap());

                // Create histograms
                displayHistograms(tempImage);
            }

            watch.Stop();
            string timeTaken = String.Format(" HDR {0} ms", watch.ElapsedMilliseconds.ToString());

            Console.WriteLine(timeTaken);
            labelOutput.Content += timeTaken;
        }
Exemplo n.º 2
0
        private void buttonCLAHE_Click(object sender, RoutedEventArgs e)
        {
            if (HDRImage == null)
            {
                System.Windows.MessageBox.Show("No HDR image generated", "Error", MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
            }

            var watch = System.Diagnostics.Stopwatch.StartNew();

            // Get parameters
            int    windowSize    = (int)getParamater(textboxAHEWindowSize);
            double contrastLimit = getParamater(textboxClipLimit);

            // Convert to MyImage
            MyImage myImage = HDRImage.ToMyImage();

            // Calculate each channel separated

            // Do paralel image process on each channel
            Parallel.ForEach(myImage.bitplane, (bitplane, state, ch) =>
            {
                // Process current channel
                ImageProcessing.CLAHE(ref bitplane, windowSize, contrastLimit);
            });

            // Create histograms
            displayHistograms(myImage);

            // Draw image on screen
            processedImage.Source = Utils.getSource(myImage.GetBitmap());

            watch.Stop();
            string timeTaken = String.Format(" CLAHE {0} ms", watch.ElapsedMilliseconds.ToString());

            Console.WriteLine(timeTaken);
            labelOutput.Content += timeTaken;
        }