public void TestLookupValues()
        {
            const double rescaleSlope     = 1.5e-9;
            const double rescaleIntercept = 351;

            var lut = new NormalizationLutLinear(rescaleSlope, rescaleIntercept);

            lut.AssertLookupValues(-65536, 65536);
        }
Beispiel #2
0
        public void ComposeUnsignedSubnormalModalityLut()
        {
            const int    bitsStored       = 13;
            const bool   isSigned         = false;
            const double windowWidth      = 8192;
            const double windowLevel      = 4096;
            const double rescaleSlope     = 3.1415926535897932384626433832795e-6;
            const double rescaleIntercept = -10;

            var modalityLut      = _lutFactory.GetModalityLutLinear(bitsStored, isSigned, rescaleSlope, rescaleIntercept);
            var normalizationLut = new NormalizationLutLinear(rescaleSlope, rescaleIntercept);
            var voiLut           = new BasicVoiLutLinear {
                WindowWidth = windowWidth, WindowCenter = windowLevel
            };
            var lutComposer = new LutComposer(bitsStored, isSigned)
            {
                ModalityLut = modalityLut, VoiLut = voiLut, NormalizationLut = normalizationLut
            };

            Assert.AreEqual(0, modalityLut.MinInputValue);
            Assert.AreEqual(8191, modalityLut.MaxInputValue);
            Assert.AreEqual(-10, modalityLut.MinOutputValue, _tolerance);
            Assert.AreEqual(-9.9742672145744464, modalityLut.MaxOutputValue, _tolerance);
            Assert.AreEqual(-10, modalityLut[0], _tolerance);
            Assert.AreEqual(-9.9742672145744464, modalityLut[8191], _tolerance);

            Assert.AreEqual(-10, normalizationLut.MinInputValue, _tolerance);
            Assert.AreEqual(-9.9742672145744464, normalizationLut.MaxInputValue, _tolerance);
            Assert.AreEqual(0, normalizationLut.MinOutputValue, _tolerance);
            Assert.AreEqual(8191, normalizationLut.MaxOutputValue, _tolerance);
            Assert.AreEqual(0, normalizationLut[-10], _tolerance);
            Assert.AreEqual(8191, normalizationLut[-9.9742672145744464], _tolerance);

            Assert.AreEqual(0, voiLut.MinInputValue, _tolerance);
            Assert.AreEqual(8191, voiLut.MaxInputValue, _tolerance);
            Assert.AreEqual(0, voiLut.MinOutputValue, _tolerance);
            Assert.AreEqual(8191, voiLut.MaxOutputValue, _tolerance);

            Assert.AreEqual(1543, voiLut[1543], _tolerance);
            Assert.AreEqual(5164, voiLut[5164], _tolerance);
            Assert.AreEqual(7074, voiLut[7074], _tolerance);

            //For this, we want the output range to be the same as the VOI.
            var output = lutComposer.GetOutputLut((int)Math.Round(voiLut.MinOutputValue), (int)Math.Round(voiLut.MaxOutputValue));

            Assert.AreEqual(1543, output.Data[1543]);
            Assert.AreEqual(5164, output.Data[5164]);
            Assert.AreEqual(7074, output.Data[7074]);
        }
Beispiel #3
0
        public void ComposeSignedSubnormalModalityLut()
        {
            const int    bitsStored       = 15;
            const bool   isSigned         = true;
            const double windowWidth      = 32768;
            const double windowLevel      = 0;
            const double rescaleSlope     = 2.7182818284590452353602874713527e-6;
            const double rescaleIntercept = 0;

            var modalityLut      = _lutFactory.GetModalityLutLinear(bitsStored, isSigned, rescaleSlope, rescaleIntercept);
            var normalizationLut = new NormalizationLutLinear(rescaleSlope, rescaleIntercept);
            var voiLut           = new BasicVoiLutLinear {
                WindowWidth = windowWidth, WindowCenter = windowLevel
            };
            var lutComposer = new LutComposer(bitsStored, isSigned)
            {
                ModalityLut = modalityLut, VoiLut = voiLut, NormalizationLut = normalizationLut
            };

            Assert.AreEqual(-16384, modalityLut.MinInputValue);
            Assert.AreEqual(16383, modalityLut.MaxInputValue);
            Assert.AreEqual(-0.044536329477473, modalityLut.MinOutputValue, _tolerance);
            Assert.AreEqual(0.044533611195644536, modalityLut.MaxOutputValue, _tolerance);
            Assert.AreEqual(-0.044536329477473, modalityLut[-16384], _tolerance);
            Assert.AreEqual(0.044533611195644536, modalityLut[16383], _tolerance);

            Assert.AreEqual(-0.044536329477473, normalizationLut.MinInputValue, _tolerance);
            Assert.AreEqual(0.044533611195644536, normalizationLut.MaxInputValue, _tolerance);
            Assert.AreEqual(-16384, normalizationLut.MinOutputValue, _tolerance);
            Assert.AreEqual(16383, normalizationLut.MaxOutputValue, _tolerance);
            Assert.AreEqual(-16384, normalizationLut[-0.044536329477473], _tolerance);
            Assert.AreEqual(16383, normalizationLut[0.044533611195644536], _tolerance);

            Assert.AreEqual(-16384, voiLut.MinInputValue, _tolerance);
            Assert.AreEqual(16383, voiLut.MaxInputValue, _tolerance);
            Assert.AreEqual(-16384, voiLut.MinOutputValue, _tolerance);
            Assert.AreEqual(16383, voiLut.MaxOutputValue, _tolerance);

            Assert.AreEqual(-13543, voiLut[-13543], _tolerance);
            Assert.AreEqual(12564, voiLut[12564], _tolerance);
            Assert.AreEqual(-4074, voiLut[-4074], _tolerance);

            //For this, we want the output range to be the same as the VOI.
            var output = lutComposer.GetOutputLut((int)Math.Round(voiLut.MinOutputValue), (int)Math.Round(voiLut.MaxOutputValue));

            Assert.AreEqual(-13543, output.Data[-13543 + 16384]);
            Assert.AreEqual(12564, output.Data[12564 + 16384]);
            Assert.AreEqual(-4074, output.Data[-4074 + 16384]);
        }
		public void ComposeUnsignedSubnormalModalityLut()
		{
			const int bitsStored = 13;
			const bool isSigned = false;
			const double windowWidth = 8192;
			const double windowLevel = 4096;
			const double rescaleSlope = 3.1415926535897932384626433832795e-6;
			const double rescaleIntercept = -10;

			var modalityLut = _lutFactory.GetModalityLutLinear(bitsStored, isSigned, rescaleSlope, rescaleIntercept);
			var normalizationLut = new NormalizationLutLinear(rescaleSlope, rescaleIntercept);
			var voiLut = new BasicVoiLutLinear {WindowWidth = windowWidth, WindowCenter = windowLevel};
			var lutComposer = new LutComposer(bitsStored, isSigned) {ModalityLut = modalityLut, VoiLut = voiLut, NormalizationLut = normalizationLut};

			Assert.AreEqual(0, modalityLut.MinInputValue);
			Assert.AreEqual(8191, modalityLut.MaxInputValue);
			Assert.AreEqual(-10, modalityLut.MinOutputValue, _tolerance);
			Assert.AreEqual(-9.9742672145744464, modalityLut.MaxOutputValue, _tolerance);
			Assert.AreEqual(-10, modalityLut[0], _tolerance);
			Assert.AreEqual(-9.9742672145744464, modalityLut[8191], _tolerance);

			Assert.AreEqual(-10, normalizationLut.MinInputValue, _tolerance);
			Assert.AreEqual(-9.9742672145744464, normalizationLut.MaxInputValue, _tolerance);
			Assert.AreEqual(0, normalizationLut.MinOutputValue, _tolerance);
			Assert.AreEqual(8191, normalizationLut.MaxOutputValue, _tolerance);
			Assert.AreEqual(0, normalizationLut[-10], _tolerance);
			Assert.AreEqual(8191, normalizationLut[-9.9742672145744464], _tolerance);

			Assert.AreEqual(0, voiLut.MinInputValue, _tolerance);
			Assert.AreEqual(8191, voiLut.MaxInputValue, _tolerance);
			Assert.AreEqual(0, voiLut.MinOutputValue);
			Assert.AreEqual(8191, voiLut.MaxOutputValue);

			Assert.AreEqual(1543, voiLut[1543]);
			Assert.AreEqual(5164, voiLut[5164]);
			Assert.AreEqual(7074, voiLut[7074]);

			Assert.AreEqual(1543, lutComposer.Data[1543]);
			Assert.AreEqual(5164, lutComposer.Data[5164]);
			Assert.AreEqual(7074, lutComposer.Data[7074]);
		}
		public void ComposeSignedSubnormalModalityLut()
		{
			const int bitsStored = 15;
			const bool isSigned = true;
			const double windowWidth = 32768;
			const double windowLevel = 0;
			const double rescaleSlope = 2.7182818284590452353602874713527e-6;
			const double rescaleIntercept = 0;

			var modalityLut = _lutFactory.GetModalityLutLinear(bitsStored, isSigned, rescaleSlope, rescaleIntercept);
			var normalizationLut = new NormalizationLutLinear(rescaleSlope, rescaleIntercept);
			var voiLut = new BasicVoiLutLinear {WindowWidth = windowWidth, WindowCenter = windowLevel};
			var lutComposer = new LutComposer(bitsStored, isSigned) {ModalityLut = modalityLut, VoiLut = voiLut, NormalizationLut = normalizationLut};

			Assert.AreEqual(-16384, modalityLut.MinInputValue);
			Assert.AreEqual(16383, modalityLut.MaxInputValue);
			Assert.AreEqual(-0.044536329477473, modalityLut.MinOutputValue, _tolerance);
			Assert.AreEqual(0.044533611195644536, modalityLut.MaxOutputValue, _tolerance);
			Assert.AreEqual(-0.044536329477473, modalityLut[-16384], _tolerance);
			Assert.AreEqual(0.044533611195644536, modalityLut[16383], _tolerance);

			Assert.AreEqual(-0.044536329477473, normalizationLut.MinInputValue, _tolerance);
			Assert.AreEqual(0.044533611195644536, normalizationLut.MaxInputValue, _tolerance);
			Assert.AreEqual(-16384, normalizationLut.MinOutputValue, _tolerance);
			Assert.AreEqual(16383, normalizationLut.MaxOutputValue, _tolerance);
			Assert.AreEqual(-16384, normalizationLut[-0.044536329477473], _tolerance);
			Assert.AreEqual(16383, normalizationLut[0.044533611195644536], _tolerance);

			Assert.AreEqual(-16384, voiLut.MinInputValue, _tolerance);
			Assert.AreEqual(16383, voiLut.MaxInputValue, _tolerance);
			Assert.AreEqual(-16384, voiLut.MinOutputValue);
			Assert.AreEqual(16383, voiLut.MaxOutputValue);

			Assert.AreEqual(-13543, voiLut[-13543]);
			Assert.AreEqual(12564, voiLut[12564]);
			Assert.AreEqual(-4074, voiLut[-4074]);

			Assert.AreEqual(-13543, lutComposer.Data[-13543 + 16384]);
			Assert.AreEqual(12564, lutComposer.Data[12564 + 16384]);
			Assert.AreEqual(-4074, lutComposer.Data[-4074 + 16384]);
		}
		public void TestLookupValues()
		{
			const double rescaleSlope = 1.5e-9;
			const double rescaleIntercept = 351;

			var lut = new NormalizationLutLinear(rescaleSlope, rescaleIntercept);

			lut.AssertLookupValues(-65536, 65536);
		}