Пример #1
0
        public byte GetColorPixelValue(int row, int col, COLORID colorId)
        {
            LazyLoadPixels();

            if ((_samplesPerPixel == 3) && (_bitsAllocated == 8))
            {
                int index = row * (_imageWidth * _samplesPerPixel) + (col * _samplesPerPixel) + (int)colorId;
                if (index > _imageHeight * _imageWidth * 3)
                {
                    return(0);
                }
                return(_pixels24[index]);
            }
            if ((_samplesPerPixel == 1) && (_bitsAllocated == 16))
            {
                // color images have 4 ushorts per color value when _bitsAllocated == 16
                // Also assume that there is only 1 frame!
                int index = (row * _imageWidth * 2) + (col * 2);

                if (index >= _imageHeight * _imageWidth)
                {
                    return(0);
                }

                // we have a valid index representing the pixel to retrieve the color for...
                switch (colorId)
                {
                case COLORID.RED:
                    return((byte)(_pixels16[0][index] / 4095.0 * 255));

                case COLORID.GREEN:
                    return((byte)(_pixels16[0][index + 3] / 4095.0 * 255));

                case COLORID.BLUE:
                    return((byte)(_pixels16[0][index + 1] / 4095.0 * 255));
                }
            }

            throw (new Exception("Invalid dicom image passed to GetColorPixelValue! (Invalid Samples or BitDepth)"));
        }
Пример #2
0
 public byte GetColorPixelValue(float row, float col, COLORID colorId)
 {
     return(_dicomDecoder.GetColorPixelValue((int)row, (int)col, colorId));
 }