private void ApplyFilter()
        {
            RasterImage runImage = _originalBitmap.Clone();

            try
            {
                MultiscaleEnhancementCommandType type = MultiscaleEnhancementCommandType.Gaussian;
                switch (_cbFilter.SelectedIndex)
                {
                case 0:
                    type = MultiscaleEnhancementCommandType.Normal;
                    break;

                case 1:
                    type = MultiscaleEnhancementCommandType.Resample;
                    break;

                case 2:
                    type = MultiscaleEnhancementCommandType.Bicubic;
                    break;

                case 3:
                    type = MultiscaleEnhancementCommandType.Gaussian;
                    break;
                }
                MultiscaleEnhancementCommandFlags flags = MultiscaleEnhancementCommandFlags.None;
                if (_cbEdge.Checked)
                {
                    flags |= MultiscaleEnhancementCommandFlags.EdgeEnhancement;
                }
                if (_cbLatitude.Checked)
                {
                    flags |= MultiscaleEnhancementCommandFlags.LatitudeReduction;
                }

                MultiscaleEnhancementCommand command = new MultiscaleEnhancementCommand(
                    Convert.ToInt32(_numContrast.Value * 100),
                    (_cbEdgeLevel.Checked) ? Convert.ToInt32(_numEdgeLevel.Value) : -1,
                    (_cbEdgeCoef.Checked) ? Convert.ToInt32(_numEdgeCoef.Value * 100) : -1,
                    (_cbLatLevel.Checked) ? Convert.ToInt32(_numLatLevel.Value) : -1,
                    (_cbLatCoef.Checked) ? Convert.ToInt32(_numLatCoef.Value * 100) : -1,
                    type,
                    flags);

                command.Run(runImage);

                _viewer.Image = runImage;
            }
            catch (System.Exception ex)
            {
                Messager.ShowError(this, ex);
            }
        }
Ejemplo n.º 2
0
        public static void MultiscaleEnhancement(RasterImage image, params string[] parameters)
        {
            MultiscaleEnhancementCommand cmd = new MultiscaleEnhancementCommand();
            int contrast, edgeLevels, edgeCoeff, latLevels, latCoeff;
            MultiscaleEnhancementCommandType enhancementType = MultiscaleEnhancementCommandType.Gaussian;

            if (parameters.Length >= 6)
            {
                if (!int.TryParse(parameters[0], out contrast))
                {
                    return;
                }

                if (!int.TryParse(parameters[1], out edgeLevels))
                {
                    return;
                }

                if (!int.TryParse(parameters[2], out edgeCoeff))
                {
                    return;
                }

                if (!int.TryParse(parameters[3], out latLevels))
                {
                    return;
                }

                if (!int.TryParse(parameters[4], out latCoeff))
                {
                    return;
                }

                parameters[5].TryParse <MultiscaleEnhancementCommandType>(out enhancementType);

                cmd.Contrast            = contrast;
                cmd.EdgeLevels          = edgeLevels;
                cmd.EdgeCoefficient     = edgeCoeff;
                cmd.LatitudeLevels      = latLevels;
                cmd.LatitudeCoefficient = latCoeff;
                cmd.Type  = enhancementType;
                cmd.Flags = cmd.Flags | MultiscaleEnhancementCommandFlags.DontUseThreading;
                cmd.Run(image);
            }
        }
Ejemplo n.º 3
0
        private void ApplyFilter()
        {
            MultiscaleEnhancementCommandType type = MultiscaleEnhancementCommandType.Gaussian;

            switch (_cbFilter.SelectedIndex)
            {
            case 0:
                type = MultiscaleEnhancementCommandType.Normal;
                break;

            case 1:
                type = MultiscaleEnhancementCommandType.Resample;
                break;

            case 2:
                type = MultiscaleEnhancementCommandType.Bicubic;
                break;

            case 3:
                type = MultiscaleEnhancementCommandType.Gaussian;
                break;
            }
            MultiscaleEnhancementCommandFlags flags = MultiscaleEnhancementCommandFlags.None;

            if (_cbEdge.Checked)
            {
                flags |= MultiscaleEnhancementCommandFlags.EdgeEnhancement;
            }
            if (_cbLatitude.Checked)
            {
                flags |= MultiscaleEnhancementCommandFlags.LatitudeReduction;
            }

            MultiscaleEnhancementCommand command = new MultiscaleEnhancementCommand(
                Convert.ToInt32(_numContrast.Value * 100),
                (_cbEdgeLevel.Checked) ? Convert.ToInt32(_numEdgeLevel.Value) : -1,
                (_cbEdgeCoef.Checked) ? Convert.ToInt32(_numEdgeCoef.Value * 100) : -1,
                (_cbLatLevel.Checked) ? Convert.ToInt32(_numLatLevel.Value) : -1,
                (_cbLatCoef.Checked) ? Convert.ToInt32(_numLatCoef.Value * 100) : -1,
                type,
                flags);

            _mainForm.FilterRunCommand(command, true, false);
        }
Ejemplo n.º 4
0
        private void ApplyFilter()
        {
            try
            {
                RasterImage runImage = _originalBitmap.Clone();

                if (_cbInvert.Checked)
                {
                    runImage.UseLookupTable = false;
                    InvertCommand invComd = new InvertCommand();
                    invComd.Run(runImage);
                }

                BackGroundRemovalCommand backgroundRemovalCommand = new BackGroundRemovalCommand(Convert.ToInt32(_numRemovalFactor.Value));
                backgroundRemovalCommand.Run(runImage);

                MinMaxValuesCommand minMaxCmd = new MinMaxValuesCommand();
                minMaxCmd.Run(runImage);
                int min = minMaxCmd.MinimumValue;
                int max = minMaxCmd.MaximumValue;

                if (_cbEnableEnhancements.Checked)
                {
                    AverageCommand avrcmd = new AverageCommand();
                    avrcmd.Dimension = 5;
                    avrcmd.Run(runImage);

                    MultiscaleEnhancementCommand MSECommand = new MultiscaleEnhancementCommand();
                    MSECommand.Contrast            = Convert.ToInt32(_numContrast.Value * 100);
                    MSECommand.EdgeCoefficient     = Convert.ToInt32(_numEdgeCoef.Value * 100);
                    MSECommand.EdgeLevels          = Convert.ToInt32(_numEdgeLevel.Value);
                    MSECommand.LatitudeCoefficient = 140;
                    MSECommand.LatitudeLevels      = 5;
                    MSECommand.Flags = MultiscaleEnhancementCommandFlags.EdgeEnhancement | MultiscaleEnhancementCommandFlags.LatitudeReduction;
                    MSECommand.Type  = MultiscaleEnhancementCommandType.Gaussian;
                    MSECommand.Run(runImage);
                }
                else
                {
                    AverageCommand avrcmd = new AverageCommand();
                    avrcmd.Dimension = 3;
                    avrcmd.Run(runImage);
                }

                ApplyLinearVoiLookupTableCommand voiCmd = new ApplyLinearVoiLookupTableCommand();
                voiCmd.Center = (min + max) / 2;
                voiCmd.Width  = max - min;
                voiCmd.Flags  = VoiLookupTableCommandFlags.UpdateMinMax;
                voiCmd.Run(runImage);

                GetLinearVoiLookupTableCommand voiLutCommand = new GetLinearVoiLookupTableCommand(GetLinearVoiLookupTableCommandFlags.None);
                voiLutCommand.Run(runImage);
                _form.WindowLevelWidth  = (int)voiLutCommand.Width;
                _form.WindowLevelCenter = (int)voiLutCommand.Center;

                _viewer.Image = runImage;
            }
            catch (System.Exception /*ex*/)
            {
            }
        }