Ejemplo n.º 1
0
        public void BatchConvertByteFloat()
        {
            var b    = new byte[] { 0, 1, 2, 3, 4 };
            var outB = new float[5];

            VolumeRescaleConvert.BatchConvert(Nifti1Datatype.DT_UNSIGNED_CHAR, b, outB, 1, 1)(0, 5);

            Assert.IsTrue(b.Zip(outB, (v1, v2) => v1 == v2 - 1).All(v => v));
        }
Ejemplo n.º 2
0
        public void BatchConvertByteByteSaturate()
        {
            var b    = new byte[] { 1, 2, 3, 4, 5 };
            var outB = new byte[5];

            VolumeRescaleConvert.BatchConvert(Nifti1Datatype.DT_UNSIGNED_CHAR, b, outB, 255, 1)(0, 5);

            Assert.IsTrue(b.Zip(outB, (v1, v2) => v2 == 255).All(v => v));
        }
Ejemplo n.º 3
0
        public void BatchConvertByteUshort()
        {
            var bufSize = 10;
            var buffer  = new byte[sizeof(ushort) * bufSize];

            using (var memStream = new MemoryStream(buffer))
            {
                using (var br = new BinaryWriter(memStream, System.Text.Encoding.Default, true))
                {
                    for (var i = 0; i < bufSize; i++)
                    {
                        br.Write((ushort)i);
                    }
                }
            }

            var outB = new byte[bufSize];

            VolumeRescaleConvert.BatchConvert(Nifti1Datatype.DT_SIGNED_SHORT, buffer, outB, 1, 1)(0, bufSize - 1);

            Assert.IsTrue(Enumerable.Range(0, bufSize).Zip(outB, (v1, v2) => v1 == v2 - 1).All(v => v));
        }