Example #1
0
        public void TestGetPixelAspectRatioString()
        {
            using (var dataset = CreateMockDataset("CR", SopClass.ComputedRadiographyImageStorage, null, new SizeF(0.6f, 0.5f), "FIDUCIAL", "details", null))
                using (var sop = (ImageSop)Sop.Create(dataset))
                {
                    var normalizedPixelSpacing = new NormalizedPixelSpacing(sop.Frames[1]);
                    Assert.AreEqual(@"5\6", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

                    normalizedPixelSpacing.Calibrate(0.33333331, 0.3333333);
                    Assert.AreEqual(@"1\1", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

                    normalizedPixelSpacing.Calibrate(0.7074200013, 0.7074200009);
                    Assert.AreEqual(@"1\1", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

                    normalizedPixelSpacing.Calibrate(0.3, 0.4);
                    Assert.AreEqual(@"3\4", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

                    normalizedPixelSpacing.Calibrate(0.4, 0.3000001);
                    Assert.AreEqual(@"4\3", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

                    normalizedPixelSpacing.Calibrate(0.55, 0.4);
                    Assert.AreEqual(@"11\8", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

                    normalizedPixelSpacing.Calibrate(0.7777777, 0.3333333);
                    Assert.AreEqual(@"7\3", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");
                }
        }
Example #2
0
 public void TestManualCalibration()
 {
     using (var dataset = CreateMockDataset("CR", SopClass.ComputedRadiographyImageStorage, null, new SizeF(0.6f, 0.5f), "FIDUCIAL", "details", null))
     {
         using (var sop = (ImageSop)Sop.Create(dataset))
         {
             var normalizedPixelSpacing = new NormalizedPixelSpacing(sop.Frames[1]);
             normalizedPixelSpacing.Calibrate(0.3, 0.4);
             Console.WriteLine(GetPixelSpacingAttributeInfo(dataset));
             Assert.AreEqual(false, normalizedPixelSpacing.IsNull, "IsNull property");
             Assert.AreEqual(0.3, normalizedPixelSpacing.Row, _tolerance, "Row property");
             Assert.AreEqual(0.4, normalizedPixelSpacing.Column, _tolerance, "Column property");
             Assert.AreEqual(NormalizedPixelSpacingCalibrationType.Manual, normalizedPixelSpacing.CalibrationType, "CalibrationType property");
             Assert.AreEqual(string.Empty, normalizedPixelSpacing.CalibrationDetails, "CalibrationDetails property");
         }
     }
 }
		public void TestGetPixelAspectRatioString()
		{
			using (var dataset = CreateMockDataset("CR", SopClass.ComputedRadiographyImageStorage, null, new SizeF(0.6f, 0.5f), "FIDUCIAL", "details", null))
			using (var sop = (ImageSop) Sop.Create(dataset))
			{
				var normalizedPixelSpacing = new NormalizedPixelSpacing(sop.Frames[1]);
				Assert.AreEqual(@"5\6", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

				normalizedPixelSpacing.Calibrate(0.33333331, 0.3333333);
				Assert.AreEqual(@"1\1", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

				normalizedPixelSpacing.Calibrate(0.7074200013, 0.7074200009);
				Assert.AreEqual(@"1\1", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

				normalizedPixelSpacing.Calibrate(0.3, 0.4);
				Assert.AreEqual(@"3\4", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

				normalizedPixelSpacing.Calibrate(0.4, 0.3000001);
				Assert.AreEqual(@"4\3", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

				normalizedPixelSpacing.Calibrate(0.55, 0.4);
				Assert.AreEqual(@"11\8", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");

				normalizedPixelSpacing.Calibrate(0.7777777, 0.3333333);
				Assert.AreEqual(@"7\3", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");
			}
		}
		public void TestManualCalibration()
		{
			using (var dataset = CreateMockDataset("CR", SopClass.ComputedRadiographyImageStorage, null, new SizeF(0.6f, 0.5f), "FIDUCIAL", "details", null))
			{
				using (var sop = (ImageSop) Sop.Create(dataset))
				{
					var normalizedPixelSpacing = new NormalizedPixelSpacing(sop.Frames[1]);
					normalizedPixelSpacing.Calibrate(0.3, 0.4);
					Console.WriteLine(GetPixelSpacingAttributeInfo(dataset));
					Assert.AreEqual(false, normalizedPixelSpacing.IsNull, "IsNull property");
					Assert.AreEqual(0.3, normalizedPixelSpacing.Row, _tolerance, "Row property");
					Assert.AreEqual(0.4, normalizedPixelSpacing.Column, _tolerance, "Column property");
					Assert.AreEqual(NormalizedPixelSpacingCalibrationType.Manual, normalizedPixelSpacing.CalibrationType, "CalibrationType property");
					Assert.AreEqual(string.Empty, normalizedPixelSpacing.CalibrationDetails, "CalibrationDetails property");
					Assert.AreEqual(@"3\4", normalizedPixelSpacing.GetPixelAspectRatioString(), "GetPixelAspectRatioString result");
				}
			}
		}