public void TestVolumeU16() { const ushort expectedMinimum = 100; const ushort expectedMaximum = 200; var rng = new PseudoRandom(0x48E4B0B4); var data = new ushort[1000]; for (var n = 1; n < data.Length - 1; ++n) { data[n] = (ushort)rng.Next(expectedMinimum + 1, expectedMaximum - 1); } data[0] = expectedMaximum; data[999] = expectedMinimum; var volume = new U16Volume(data, new Size3D(5, 10, 20), new Vector3D(2, 1, 0.5f), new Vector3D(5, 0, -5), new Matrix3D(new float[, ] { { 0, 1, 0 }, { 0, 0, 1 }, { 1, 0, 0 } }), new DicomAttributeCollection(), 123); Assert.AreSame(data, volume.Array, "Array"); Assert.AreSame(data, volume.ArrayData, "ArrayData"); Assert.AreEqual(new Size3D(5, 10, 20), volume.ArrayDimensions, "ArrayDimensions"); Assert.AreEqual(1000, volume.ArrayLength, "ArrayLength"); Assert.AreEqual(16, volume.BitsPerVoxel, "BitsPerVoxel"); Assert.AreEqual(false, volume.Signed, "Signed"); Assert.AreEqual(123, volume.PaddingValue, "PaddingValue"); Assert.AreEqual(new Vector3D(10, 10, 10), volume.VolumeSize, "VolumeSize"); Assert.AreEqual(new Rectangle3D(0, 0, 0, 10, 10, 10), volume.VolumeBounds, "VolumeBounds"); Assert.AreEqual(new Vector3D(5, 5, 5), volume.VolumeCenter, "VolumeCenter"); Assert.AreEqual(new Vector3D(10, 5, 0), volume.VolumeCenterPatient, "VolumeCenterPatient"); Assert.AreEqual(new Vector3D(0, 1, 0), volume.VolumeOrientationPatientX, "VolumeOrientationPatientX"); Assert.AreEqual(new Vector3D(0, 0, 1), volume.VolumeOrientationPatientY, "VolumeOrientationPatientY"); Assert.AreEqual(new Vector3D(1, 0, 0), volume.VolumeOrientationPatientZ, "VolumeOrientationPatientZ"); Assert.AreEqual(new Vector3D(5, 0, -5), volume.VolumePositionPatient, "VolumePositionPatient"); Assert.AreEqual(expectedMinimum, volume.MinimumVolumeValue, "MinimumVolumeValue"); Assert.AreEqual(expectedMaximum, volume.MaximumVolumeValue, "MaximumVolumeValue"); }
private static void CreateAndResliceVolume(bool signed) { const int width = 10; const int height = 10; const int depth = 10; Volume vol; if (signed) { vol = new S16Volume(new short[width * height * depth], new Size3D(width, height, depth), new Vector3D(1, 1, 1), new Vector3D(0, 0, 0), Matrix3D.GetIdentity(), new DicomAttributeCollection() { ValidateVrLengths = false, ValidateVrValues = false }, short.MinValue); } else { vol = new U16Volume(new ushort[width * height * depth], new Size3D(width, height, depth), new Vector3D(1, 1, 1), new Vector3D(0, 0, 0), Matrix3D.GetIdentity(), new DicomAttributeCollection(), ushort.MinValue); } try { using (var volumeReference = vol.CreateReference()) { GetSlicePixelData(volumeReference, Matrix.GetIdentity(4), 20, 20, 0.5f, 0.5f, VolumeInterpolationMode.Linear); GetSlabPixelData(volumeReference, Matrix.GetIdentity(4), new Vector3D(0, 0, 1), 20, 20, 3, 0.5f, 0.5f, 1, VolumeInterpolationMode.Linear, VolumeProjectionMode.Average); } } finally { vol.Dispose(); } }
public void TestVolumeU16() { const ushort expectedMinimum = 100; const ushort expectedMaximum = 200; var rng = new PseudoRandom(0x48E4B0B4); var data = new ushort[1000]; for (var n = 1; n < data.Length - 1; ++n) data[n] = (ushort) rng.Next(expectedMinimum + 1, expectedMaximum - 1); data[0] = expectedMaximum; data[999] = expectedMinimum; var volume = new U16Volume(data, new Size3D(5, 10, 20), new Vector3D(2, 1, 0.5f), new Vector3D(5, 0, -5), new Matrix3D(new float[,] {{0, 1, 0}, {0, 0, 1}, {1, 0, 0}}), new DicomAttributeCollection(), 123); Assert.AreSame(data, volume.Array, "Array"); Assert.AreSame(data, volume.ArrayData, "ArrayData"); Assert.AreEqual(new Size3D(5, 10, 20), volume.ArrayDimensions, "ArrayDimensions"); Assert.AreEqual(1000, volume.ArrayLength, "ArrayLength"); Assert.AreEqual(16, volume.BitsPerVoxel, "BitsPerVoxel"); Assert.AreEqual(false, volume.Signed, "Signed"); Assert.AreEqual(123, volume.PaddingValue, "PaddingValue"); Assert.AreEqual(new Vector3D(10, 10, 10), volume.VolumeSize, "VolumeSize"); Assert.AreEqual(new Rectangle3D(0, 0, 0, 10, 10, 10), volume.VolumeBounds, "VolumeBounds"); Assert.AreEqual(new Vector3D(5, 5, 5), volume.VolumeCenter, "VolumeCenter"); Assert.AreEqual(new Vector3D(10, 5, 0), volume.VolumeCenterPatient, "VolumeCenterPatient"); Assert.AreEqual(new Vector3D(0, 1, 0), volume.VolumeOrientationPatientX, "VolumeOrientationPatientX"); Assert.AreEqual(new Vector3D(0, 0, 1), volume.VolumeOrientationPatientY, "VolumeOrientationPatientY"); Assert.AreEqual(new Vector3D(1, 0, 0), volume.VolumeOrientationPatientZ, "VolumeOrientationPatientZ"); Assert.AreEqual(new Vector3D(5, 0, -5), volume.VolumePositionPatient, "VolumePositionPatient"); Assert.AreEqual(expectedMinimum, volume.MinimumVolumeValue, "MinimumVolumeValue"); Assert.AreEqual(expectedMaximum, volume.MaximumVolumeValue, "MaximumVolumeValue"); }