Ejemplo n.º 1
0
        public void From16bit_Constructor_Correct()
        {
            Random rnd   = new Random();
            var    ims16 = new ImageStack16(43, 43, 41, 41, ImageStack.SliceOrders.ZBeforeT);
            //quickly fill image with random values
            int *buffer = (int *)ims16.ImageData;
            long iter   = ims16.ImageNB / 4;

            for (long i = 0; i < iter; i++)
            {
                buffer[i] = rnd.Next();
            }
            var ims32 = new ImageStack32F(ims16);

            Assert.AreEqual(ims16.SliceOrder, ims32.SliceOrder);
            for (int z = 0; z < ims16.ZPlanes; z++)
            {
                for (int t = 0; t < ims16.TimePoints; t++)
                {
                    for (int y = 0; y < ims16.ImageHeight; y++)
                    {
                        for (int x = 0; x < ims16.ImageWidth; x++)
                        {
                            Assert.AreEqual(*ims16[x, y, z, t], *ims32[x, y, z, t], *ims16[x, y, z, t] / 1000);
                        }
                    }
                }
            }
            ims16.Dispose();
            ims32.Dispose();
        }
Ejemplo n.º 2
0
        public void RangeCheck_OnPixelAccess()
        {
            var ims = new ImageStack32F(5, 5, 5, 5, ImageStack.SliceOrders.ZBeforeT);
            var p   = ims[5, 0, 0, 0];

            ims.Dispose();
        }
Ejemplo n.º 3
0
        public void PixelPointerNull_AfterDispose()
        {
            var ims = new ImageStack32F(5, 5, 5, 5, ImageStack.SliceOrders.ZBeforeT);

            ims.Dispose();
            Assert.IsTrue(ims[4, 0, 0, 0] == null);
        }
Ejemplo n.º 4
0
        public void Construction_WithValidArguments_DimCorrect()
        {
            int w   = 20;
            int h   = 30;
            int z   = 40;
            int t   = 50;
            var ims = new ImageStack32F(w, h, z, t, ImageStack.SliceOrders.TBeforeZ);

            Assert.AreEqual(ims.ImageWidth, w, "Image width not correct.");
            Assert.AreEqual(ims.ImageHeight, h, "Image height not correct.");
            Assert.AreEqual(ims.ZPlanes, z, "Image z plane number not correct.");
            Assert.AreEqual(ims.TimePoints, t, "Number of timepoints not correct.");
            ims.Dispose();
        }
Ejemplo n.º 5
0
        public void CopyConstructor_Correct()
        {
            var ims = CreateDefaultStack();

            ims.SetAll(33.37f);
            var copy = new ImageStack32F(ims);

            Assert.IsFalse(ims.ImageData == copy.ImageData, "Source and its copy point to the same buffer");
            float *sourceStart = ims.ImageData;
            float *copyStart   = copy.ImageData;

            for (long i = 0; i < ims.ImageNB / 4; i++)
            {
                Assert.AreEqual(sourceStart[i], copyStart[i], sourceStart[i] / 1000, "Found non-matching pixel");
            }
            ims.Dispose();
            copy.Dispose();
        }
Ejemplo n.º 6
0
        public void Construction_WithInvalidHeight()
        {
            var ims = new ImageStack32F(20, 0, 40, 50, ImageStack.SliceOrders.TBeforeZ);

            ims.Dispose();
        }