예제 #1
0
        private void filterImage()
        {
            if ((inputLdrImage == null) || (inputLdrImage == null))
            {
                return;
            }
            Cursor.Current = Cursors.WaitCursor;

            Stopwatch sw = new Stopwatch();

            sw.Start();

            try
            {
                uint width  = inputHdrImage.Width;
                uint height = inputHdrImage.Height;
                if ((depthMap != null) &&
                    ((depthMap.Width != width) ||
                     (depthMap.Height != height)))
                {
                    throw new ArgumentException(String.Format(
                                                    "Depth map must have the same dimensions as the input image"
                                                    + " {0}x{1}, but it's size was {2}x{3}.", width, height, depthMap.Width, depthMap.Height));
                }
                AbstractSpreadingFilter filter = GetSpreadingFilter();
                filter.Blur = CreateBlurFunction(depthMap);
                //filter.SpreadOneRoundedPSF = true;
                outputHdrImage = filter.FilterImage(inputHdrImage, outputHdrImage);
                ReplaceLdrImage(ref outputLdrImage, outputHdrImage.ToBitmap(ToneMappingEnabled));
                imageTypeComboBox.SelectedIndex = 1; // TODO: select the filtered image better
                updatePictureBoxImage();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace, "Error");
            }

            sw.Stop();
            labelElapsed.Text = String.Format("Elapsed time: {0:f}s", 1.0e-3 * sw.ElapsedMilliseconds);

            Cursor.Current = Cursors.Default;
        }