コード例 #1
0
        public void FromImagePixelValueTags_ValidSignedInput_CorrectOutput(
            ushort bitsAllocated,
            ushort bitsStored,
            double rescaleSlope,
            double rescaleIntercept,
            short smallestImagePixelValue,
            short largestImagePixelValue,
            string voiLutFunction,
            double expectedWindowWidth,
            double expectedWindowCenter)
        {
            var dataset = new DicomDataset(
                new DicomCodeString(DicomTag.PhotometricInterpretation, "MONOCHROME1"),
                new DicomUnsignedShort(DicomTag.BitsAllocated, bitsAllocated),
                new DicomUnsignedShort(DicomTag.BitsStored, bitsStored),
                new DicomUnsignedShort(DicomTag.PixelRepresentation, 1),
                new DicomDecimalString(DicomTag.RescaleSlope, (decimal)rescaleSlope),
                new DicomDecimalString(DicomTag.RescaleIntercept, (decimal)rescaleIntercept),
                new DicomSignedShort(DicomTag.SmallestImagePixelValue, smallestImagePixelValue),
                new DicomSignedShort(DicomTag.LargestImagePixelValue, largestImagePixelValue),
                new DicomCodeString(DicomTag.VOILUTFunction, voiLutFunction));

            var actual = GrayscaleRenderOptions.FromImagePixelValueTags(dataset);

            Assert.Equal(expectedWindowWidth, actual.WindowWidth);
            Assert.Equal(expectedWindowCenter, actual.WindowCenter);
        }
コード例 #2
0
        public void FromDataset_PixelLimits_ReturnsSameAsFromImagePixelValueTags(
            ushort bitsAllocated,
            ushort bitsStored,
            double rescaleSlope,
            double rescaleIntercept,
            short smallestImagePixelValue,
            short largestImagePixelValue,
            string voiLutFunction,
            double expectedWindowWidth,
            double expectedWindowCenter)
        {
            var dataset = new DicomDataset(
                new DicomUnsignedShort(DicomTag.BitsAllocated, bitsAllocated),
                new DicomUnsignedShort(DicomTag.BitsStored, bitsStored),
                new DicomUnsignedShort(DicomTag.PixelRepresentation, 1),
                new DicomDecimalString(DicomTag.RescaleSlope, (decimal)rescaleSlope),
                new DicomDecimalString(DicomTag.RescaleIntercept, (decimal)rescaleIntercept),
                new DicomSignedShort(DicomTag.SmallestImagePixelValue, smallestImagePixelValue),
                new DicomSignedShort(DicomTag.LargestImagePixelValue, largestImagePixelValue),
                new DicomCodeString(DicomTag.VOILUTFunction, voiLutFunction));

            var expected = GrayscaleRenderOptions.FromImagePixelValueTags(dataset);
            var actual   = GrayscaleRenderOptions.FromDataset(dataset);

            Assert.Equal(expected.WindowWidth, actual.WindowWidth);
            Assert.Equal(expected.WindowCenter, actual.WindowCenter);
        }
コード例 #3
0
        public void FromImagePixelValueTags_SmallestGreaterThanLargest_Throws()
        {
            var dataset = new DicomDataset(
                new DicomUnsignedShort(DicomTag.BitsAllocated, 8),
                new DicomUnsignedShort(DicomTag.BitsStored, 8),
                new DicomUnsignedShort(DicomTag.PixelRepresentation, 0),
                new DicomDecimalString(DicomTag.RescaleSlope, (decimal)1),
                new DicomDecimalString(DicomTag.RescaleIntercept, (decimal)0),
                new DicomUnsignedShort(DicomTag.SmallestImagePixelValue, 180),
                new DicomUnsignedShort(DicomTag.LargestImagePixelValue, 90),
                new DicomCodeString(DicomTag.VOILUTFunction, "LINEAR"));

            Assert.Throws <DicomImagingException>(() => GrayscaleRenderOptions.FromImagePixelValueTags(dataset));
        }