public void FragmentImage_blockSizeGreatedThanRealSize()
        {
            FragmentationResult results = Fragmenter.FragmentImage(
                testImage,
                new SizeF(200, 100),
                300, 50
                );

            Assert.IsNull(results);
        }
        public void FragmentImage_downscale()
        {
            FragmentationResult results = Fragmenter.FragmentImage(
                testImage,
                new SizeF(200, 100),
                50, 6
                );

            Assert.AreEqual(1, results.Blocks.Rows);
            Assert.AreEqual(3, results.Blocks.Cols);
            Assert.AreEqual(19, results.MarginTop);
            Assert.AreEqual(13, results.MarginLeft);
        }
        public void FragmentImage_upscale()
        {
            FragmentationResult results = Fragmenter.FragmentImage(
                testImage,
                new SizeF(200, 100),
                12, 2
                );

            Assert.AreEqual(7, results.Blocks.Rows);
            Assert.AreEqual(14, results.Blocks.Cols);
            Assert.AreEqual(0, results.MarginTop);
            Assert.AreEqual(1, results.MarginLeft);

            // Color values are not tested, as they are mainly dependend on 3-party code
        }
Beispiel #4
0
        private bool FragmentImage(Image <Bgr, byte> i)
        {
            Sizes sizes = ReadSizes();

            if (sizes.IsInvalid())
            {
                return(false);
            }

            Emgu.CV.CvEnum.Inter interpolationMethod = (Emgu.CV.CvEnum.Inter)interpolationMethodInput.SelectedItem;

            FragmentationResult result = Fragmenter.FragmentImage(
                i,
                new SizeF((float)sizes.realWidth, (float)sizes.realHeight),
                sizes.blockSize, sizes.frameSize,
                interpolationMethod
                );

            fragmentedImage = result.Blocks;
            return(true);
        }