示例#1
0
        private static void SetWindowLevel(RasterImage derivedImage, DicomDataSet derivedDataSet)
        {
            if (derivedImage.GetLookupTable() != null)
            {
                GetLinearVoiLookupTableCommand cmd = new GetLinearVoiLookupTableCommand();
                cmd.Run(derivedImage);

                derivedDataSet.InsertElementAndSetValue(DicomTag.WindowCenter, cmd.Center);
                derivedDataSet.InsertElementAndSetValue(DicomTag.WindowWidth, cmd.Width);
            }
            else
            {
                derivedDataSet.InsertElementAndSetValue(DicomTag.WindowCenter, 127);
                derivedDataSet.InsertElementAndSetValue(DicomTag.WindowWidth, 255);
            }
        }
示例#2
0
        private void ApplyFilter()
        {
            _mainForm.FilterRunCommand(_command, false, false);

            if (_cell.Image.BitsPerPixel == 16)
            {
                int orignalPage = _cell.Image.Page;
                _cell.Image.Page = _cell.ActiveSubCell + 1;

                GetLinearVoiLookupTableCommand voiLut = new GetLinearVoiLookupTableCommand();
                voiLut.Run(_cell.Image);

                _cell.Image.Page = orignalPage;

                _cell.SetWindowLevel(_cell.ActiveSubCell, (int)voiLut.Width, (int)voiLut.Center);
            }

            _cell.Invalidate();
        }
示例#3
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*/)
            {
            }
        }