コード例 #1
0
        private async Task DisjunctOriginalImageWithBackgroundBuffer()
        {
            await _loadImageTask;

            if (_backgroundBuffer == null ||
                _backgroundBuffer.Width != _originalImage.Width ||
                _backgroundBuffer.Height != _originalImage.Height)
            {
                GenerateBackgroundBuffer(_originalImage.Width, _originalImage.Height);
            }

            _disjunctionOfOriginalImageWithBackgroundBuffer = new RgbImage <byte>
            {
                Width       = _originalImage.Width,
                Height      = _originalImage.Height,
                ImmageArray = new byte[RowsCount, 3]
            };

            for (int i = 0; i < RowsCount; i++)
            {
                _disjunctionOfOriginalImageWithBackgroundBuffer.ImmageArray[i, 0] =
                    (byte)(_originalImage.ImmageArray[i, 0] | _backgroundBuffer.ImmageArray[i, 0]);

                _disjunctionOfOriginalImageWithBackgroundBuffer.ImmageArray[i, 1] =
                    (byte)(_originalImage.ImmageArray[i, 1] | _backgroundBuffer.ImmageArray[i, 1]);

                _disjunctionOfOriginalImageWithBackgroundBuffer.ImmageArray[i, 2] =
                    (byte)(_originalImage.ImmageArray[i, 2] | _backgroundBuffer.ImmageArray[i, 2]);
            }
        }
コード例 #2
0
        private void GenerateBackgroundBuffer(int width, int height)
        {
            _backgroundBuffer = new RgbImage <byte>
            {
                Width       = width,
                Height      = height,
                ImmageArray = new byte[RowsCount, 3]
            };

            for (int i = 0; i < RowsCount; i++)
            {
                _backgroundBuffer.ImmageArray[i, 0]         =
                    _backgroundBuffer.ImmageArray[i, 1]     =
                        _backgroundBuffer.ImmageArray[i, 2] = height / 2 * width > i ? byte.MinValue : byte.MaxValue;
            }
        }
コード例 #3
0
        private async Task GenerateGradientedOriginalImage()
        {
            await _loadImageTask;

            _gradientedOriginalImage = new RgbImage <byte>()
            {
                Width       = _originalImage.Width,
                Height      = _originalImage.Height,
                ImmageArray = new byte[RowsCount, 3]
            };

            for (int i = 0; i < RowsCount; i++)
            {
                _gradientedOriginalImage.ImmageArray[i, 0]     =
                    _gradientedOriginalImage.ImmageArray[i, 1] =
                        0;

                _gradientedOriginalImage.ImmageArray[i, 2] =
                    GetColorValueFromGradientMeasure(_originalImage.ImmageArray[i, 2]);
            }
        }
コード例 #4
0
        private Task LoadDcmImage(string dcmPath)
        {
            return(Task.Run(() =>
            {
                var dcmObj = DICOMObject.Read(dcmPath);

                var rowsTag = new Tag("0028", "0010");
                var columnsTag = new Tag("0028", "0011");
                var bitsAllocatedTag = new Tag("0028", "0100");

                var bitsAllocated = dcmObj.FindFirst(bitsAllocatedTag);

                var stream = dcmObj.PixelStream;

                switch ((ushort)bitsAllocated.DData)
                {
                case 8:

                    var pixels = new byte[stream.Length];
                    stream.Read(pixels, 0, pixels.Length);

                    _originalImage = new RgbImage <byte>
                    {
                        ImmageArray = ConvertToRgb(pixels),
                        Width = (ushort)dcmObj.FindFirst(columnsTag).DData,
                        Height = (ushort)dcmObj.FindFirst(rowsTag).DData
                    };

                    break;

                default:
                    MessageBox.Show($"Given bits allocated value ({bitsAllocated}) isn't supported!");
                    break;
                }
            }));
        }