Example #1
0
        private void btnProcess_Click(object sender, EventArgs e)
        {
            pbInput.Image = InputBitmap;

            EnergyFuncType    energyFuncType    = (EnergyFuncType)cmbEnergyFuncType.SelectedIndex;
            Bitmap            resultBitmap      = null;
            SeamCarvingMethod seamCarvingMethod = (SeamCarvingMethod)cmbSeamCarvingMethod.SelectedIndex;
            double            widthRatio        = double.Parse(tbWidthRatio.Text);
            double            heightRatio       = double.Parse(tbHeightRatio.Text);

            int newWidth  = (int)Math.Round(widthRatio * InputBitmap.Width);
            int newHeight = (int)Math.Round(heightRatio * InputBitmap.Height);
            var stopwatch = new Stopwatch();

            switch (seamCarvingMethod)
            {
            case SeamCarvingMethod.CAIR:
                Thread.Sleep(100);
                stopwatch.Start();
                SeamCarverCair cairCarver = new SeamCarverCair(energyFuncType, cbHd.Checked, cbForwardEnergy.Checked, cbParallel.Checked, tbCairAppPath.Text);
                resultBitmap = cairCarver.Generate(InputBitmap, newWidth, newHeight);
                stopwatch.Stop();
                break;

            default:
            case SeamCarvingMethod.Standart:
                stopwatch.Start();
                SeamCarverStandart standrtCarver = new SeamCarverStandart(energyFuncType, cbHd.Checked, cbForwardEnergy.Checked, cbParallel.Checked,
                                                                          double.Parse(tbNeighbourCountRatio.Text), int.Parse(tbBlockSize.Text));
                resultBitmap = standrtCarver.Generate(InputBitmap, newWidth, newHeight);
                stopwatch.Stop();
                break;

            case SeamCarvingMethod.GPU:
                stopwatch.Start();
                SeamCarverGPU gpuCarver = new SeamCarverGPU(energyFuncType, cbHd.Checked, cbForwardEnergy.Checked, cbParallel.Checked,
                                                            int.Parse(tbBlockSize.Text));
                resultBitmap = gpuCarver.Generate(InputBitmap, newWidth, newHeight);
                stopwatch.Stop();
                break;
            }
            tbCalculationTime.Text = stopwatch.Elapsed.ToString();

            pbOutput.Image = resultBitmap;
        }
Example #2
0
        private void btnProcess_Click(object sender, EventArgs e)
        {
            pbInput.Image = InputBitmap;

            EnergyFuncType energyFuncType = (EnergyFuncType)cmbEnergyFuncType.SelectedIndex;
            Bitmap resultBitmap = null;
            SeamCarvingMethod seamCarvingMethod = (SeamCarvingMethod)cmbSeamCarvingMethod.SelectedIndex;
            double widthRatio = double.Parse(tbWidthRatio.Text);
            double heightRatio = double.Parse(tbHeightRatio.Text);

            int newWidth = (int)Math.Round(widthRatio * InputBitmap.Width);
            int newHeight = (int)Math.Round(heightRatio * InputBitmap.Height);
            var stopwatch = new Stopwatch();
            switch (seamCarvingMethod)
            {
                case SeamCarvingMethod.CAIR:
                    Thread.Sleep(100);
                    stopwatch.Start();
                    SeamCarverCair cairCarver = new SeamCarverCair(energyFuncType, cbHd.Checked, cbForwardEnergy.Checked, cbParallel.Checked, tbCairAppPath.Text);
                    resultBitmap = cairCarver.Generate(InputBitmap,newWidth, newHeight);
                    stopwatch.Stop();
                    break;
                default:
                case SeamCarvingMethod.Standart:
                    stopwatch.Start();
                    SeamCarverStandart standrtCarver = new SeamCarverStandart(energyFuncType, cbHd.Checked, cbForwardEnergy.Checked, cbParallel.Checked,
                        double.Parse(tbNeighbourCountRatio.Text), int.Parse(tbBlockSize.Text));
                    resultBitmap = standrtCarver.Generate(InputBitmap, newWidth, newHeight);
                    stopwatch.Stop();
                    break;
                case SeamCarvingMethod.GPU:
                    stopwatch.Start();
                    SeamCarverGPU gpuCarver = new SeamCarverGPU(energyFuncType, cbHd.Checked, cbForwardEnergy.Checked, cbParallel.Checked,
                        int.Parse(tbBlockSize.Text));
                    resultBitmap = gpuCarver.Generate(InputBitmap, newWidth, newHeight);
                    stopwatch.Stop();
                    break;
            }
            tbCalculationTime.Text = stopwatch.Elapsed.ToString();

            pbOutput.Image = resultBitmap;
        }