public TestPresentationImage DeserializeSpatialTransform(SpatialTransformModuleIod dataset)
        {
            TestPresentationImage image = new TestPresentationImage();

            base.DeserializeSpatialTransform(dataset, image);
            return(image);
        }
        public SpatialTransformModuleIod SerializeSpatialTransform(TestPresentationImage image)
        {
            SpatialTransformModuleIod dataset = new SpatialTransformModuleIod();

            base.SerializeSpatialTransform(dataset, CreateImageCollection(image));
            return(dataset);
        }
 protected void SerializeSpatialTransform(SpatialTransformModuleIod spatialTransformModule, DicomPresentationImageCollection <T> images)
 {
     foreach (T image in images)
     {
         // spatial transform defines rotation in cartesian space - dicom module defines rotation as clockwise in image space
         // spatial transform defines both horizontal and vertical flip - dicom module defines horizontal flip only (vertical flip is 180 rotation plus horizontal flip)
         ISpatialTransform spatialTransform = image.SpatialTransform;
         int rotationBy90 = (((spatialTransform.RotationXY % 360) + 360) % 360) / 90;
         int flipState    = (spatialTransform.FlipX ? 2 : 0) + (spatialTransform.FlipY ? 1 : 0);
         spatialTransformModule.ImageRotation       = _spatialTransformRotationTranslation[rotationBy90 + 4 * flipState];
         spatialTransformModule.ImageHorizontalFlip = spatialTransform.FlipY ^ spatialTransform.FlipX ? ImageHorizontalFlip.Y : ImageHorizontalFlip.N;
         break;
     }
 }
        protected void DeserializeSpatialTransform(SpatialTransformModuleIod module, T image)
        {
            ISpatialTransform spatialTransform = image.SpatialTransform;

            if (spatialTransform is IImageSpatialTransform)
            {
                IImageSpatialTransform iist = (IImageSpatialTransform)spatialTransform;
                iist.ScaleToFit = false;
            }

            if (module.ImageHorizontalFlip == ImageHorizontalFlip.Y)
            {
                spatialTransform.FlipX      = false;
                spatialTransform.FlipY      = true;
                spatialTransform.RotationXY = (360 - module.ImageRotation) % 360;
            }
            else
            {
                spatialTransform.FlipX      = false;
                spatialTransform.FlipY      = false;
                spatialTransform.RotationXY = module.ImageRotation;
            }
        }
예제 #5
0
        public void TestIodRoundtripSpatialTransform()
        {
            TestPresentationState ps = new TestPresentationState();

            for (int rotation = 0; rotation < 360; rotation += 90)
            {
                for (int flipH = 0; flipH < 2; flipH++)
                {
                    Trace.WriteLine(string.Format("Testing Roundtrip IOD->IMG->IOD with params Rot={0}, fH={1}", rotation, flipH));

                    SpatialTransformModuleIod original = new SpatialTransformModuleIod();
                    original.ImageHorizontalFlip = (flipH == 1) ? ImageHorizontalFlip.Y : ImageHorizontalFlip.N;
                    original.ImageRotation       = rotation;

                    TestPresentationImage image = ps.DeserializeSpatialTransform(original);
                    using (image)
                    {
                        SpatialTransformModuleIod actual = ps.SerializeSpatialTransform(image);
                        Assert.AreEqual(original.ImageHorizontalFlip, actual.ImageHorizontalFlip, string.Format("Roundtrip IOD->IMG->IOD FAILED: Rot={0}, fH={1}", rotation, flipH));
                        Assert.AreEqual(original.ImageRotation, actual.ImageRotation, string.Format("Roundtrip IOD->IMG->IOD FAILED: Rot={0}, fH={1}", rotation, flipH));
                    }
                }
            }
        }