예제 #1
0
            public float Compute(ImageDataPoint <float> point)
            {
                if (point.ImageID != _currentID)
                {
                    _currentID = point.ImageID;
                    if (point.Image.IsIntegral || DecisionTree <ImageDataPoint <float>, float[]> .IsBuilding)
                    {
                        _integralImage = new FloatArrayHandler(point.Image.RawArray, true);
                    }
                    else
                    {
                        _integralImage = IntegralImage.ComputeFloat <FloatArrayHandler>(point.Image);
                    }
                }
                int row    = point.Row;
                int column = point.Column;
                IMultichannelImage <float> image = point.Image;
                float sum = 0;

                for (int i = 0; i < _count; i++)
                {
                    if (i % 2 == 0)
                    {
                        sum += _integralImage.ComputeRectangleSum(row, column, _channels[i], _rectangles[i]);
                    }
                    else
                    {
                        sum -= _integralImage.ComputeRectangleSum(row, column, _channels[i], _rectangles[i]);
                    }
                }
                Debug.Assert(!float.IsNaN(sum), "Rectangle sum is NaN!");
                return(sum);
            }
예제 #2
0
        public override object Task2()
        {
            IntegralImage ii = new IntegralImage(powerGrid);

            (int, int, int)gridBox = (0, 0, 0);
            int bestBoxValue = int.MinValue;

            for (int size = 1; size < gridSize; size++)
            {
                for (int y = 0; y < gridSize - size; y++)
                {
                    for (int x = 0; x < gridSize - size; x++)
                    {
                        int v = ii.AreaSum(x, y, size, size);
                        if (v > bestBoxValue)
                        {
                            bestBoxValue = v;
                            gridBox      = (x - size + 1, y - size + 1, size);
                        }
                    }
                }
            }
            System.Console.WriteLine(bestBoxValue);
            return($"{gridBox.Item1},{gridBox.Item2},{gridBox.Item3}");
        }
예제 #3
0
 public void Compute(IntegralImage integral)
 {
     for (int i = 0; i < responses.Length; ++i)
     {
         responses[i].Compute(integral);
     }
 }
예제 #4
0
 public void build_integral_image()
 {
     System.Drawing.Bitmap img = new System.Drawing.Bitmap(path);
     iimg = IntegralImage.FromImage(img);
     img.Dispose();
     integral_image = true;
 }
예제 #5
0
        /// <summary>Process the filter on the specified image.</summary>
        /// <param name="image">Source image data.</param>
        protected override unsafe void ProcessFilter(UnmanagedImage image)
        {
            IntegralImage im                = IntegralImage.FromBitmap(image);
            int           width             = image.Width;
            int           height            = image.Height;
            int           widthM1           = width - 1;
            int           heightM1          = height - 1;
            int           offset            = image.Stride - width;
            int           radius            = windowSize / 2;
            float         avgBrightnessPart = 1.0f - pixelBrightnessDifferenceLimit;
            byte *        ptr               = (byte *)image.ImageData.ToPointer( );

            for (int y = 0; y < height; y++)
            {
                int y1 = (y - radius < 0) ? 0 : y - radius;
                int y2 = (y + radius > heightM1) ? heightM1 : y + radius;
                for (int x = 0; x < width; x++, ptr++)
                {
                    int   x1   = (x - radius < 0) ? 0 : x - radius;
                    int   x2   = (x + radius > widthM1) ? widthM1 : x + radius;
                    float mean = im.GetRectangleMeanUnsafe(x1, y1, x2, y2);
                    *     ptr  = (byte)((mean < upperLimit && *ptr < (int)(mean * avgBrightnessPart)) ? 0 : 255);
                }
                ptr += offset;
            }
        }
예제 #6
0
        public void TestStaticFilter0()
        {
            double[] data =
            {
                1.0, 2.0, 3.0,
                4.0, 5.0, 6.0,
                7.0, 8.0, 9.0,
            };
            Image         image          = new Image(3, data);
            IntegralImage integral_image = new IntegralImage(image);
            double        res;

            res = Filter.Filter0(integral_image, 0, 0, 1, 1, Filter.Subtract);
            Assert.AreEqual(1.0, res, TestsHelper.EPS);
            res = Filter.Filter0(integral_image, 0, 0, 2, 2, Filter.Subtract);
            Assert.AreEqual(12.0, res, TestsHelper.EPS);
            res = Filter.Filter0(integral_image, 0, 0, 3, 3, Filter.Subtract);
            Assert.AreEqual(45.0, res, TestsHelper.EPS);
            res = Filter.Filter0(integral_image, 1, 1, 2, 2, Filter.Subtract);
            Assert.AreEqual(28.0, res, TestsHelper.EPS);
            res = Filter.Filter0(integral_image, 2, 2, 1, 1, Filter.Subtract);
            Assert.AreEqual(9.0, res, TestsHelper.EPS);
            res = Filter.Filter0(integral_image, 0, 0, 3, 1, Filter.Subtract);
            Assert.AreEqual(12.0, res, TestsHelper.EPS);
            res = Filter.Filter0(integral_image, 0, 0, 1, 3, Filter.Subtract);
            Assert.AreEqual(6.0, res, TestsHelper.EPS);
        }
예제 #7
0
        public void FromImageTest()
        {
            foreach (int bitsPerPixel in new[] { 8 /*, 16*/ })
            {
                Image src = new Image(23, 20, bitsPerPixel, 200, 200);
                src.Randomize(this.random);

                IntegralImage dst = IntegralImage.FromImage(src);
                Assert.AreEqual(src.Width + 1, dst.Width);
                Assert.AreEqual(src.Height + 1, dst.Height);

                for (int x = 0; x < src.Width; x++)
                {
                    for (int y = 0; y < src.Height; y++)
                    {
                        int actual = dst[x + 1, y + 1];

                        int expected = 0;
                        for (int ix = 0; ix <= x; ix++)
                        {
                            for (int iy = 0; iy <= y; iy++)
                            {
                                expected += (int)src.GetPixel(ix, iy);
                            }
                        }

                        Assert.AreEqual(expected, actual);
                    }
                }
            }
        }
예제 #8
0
        static void Main(string[] args)
        {
            int name = 0;

            while (File.Exists($"img{name}.bmp"))
            {
                Image         img      = new Image(new Bitmap($"img{name}.bmp"));
                IntegralImage integral = new IntegralImage(img);
            }
        }
예제 #9
0
        /// <summary>
        /// Process the filter on the specified image.
        /// </summary>
        ///
        /// <param name="image">Source image data.</param>
        ///
        protected override unsafe void ProcessFilter(UnmanagedImage image)
        {
            // create integral image
            IntegralImage im = IntegralImage.FromBitmap(image);

            int width    = image.Width;
            int height   = image.Height;
            int widthM1  = width - 1;
            int heightM1 = height - 1;

            int offset = image.Stride - width;
            int radius = windowSize / 2;

            float avgBrightnessPart = 1.0f - pixelBrightnessDifferenceLimit;

            byte *ptr = (byte *)image.ImageData.ToPointer( );

            for (int y = 0; y < height; y++)
            {
                // rectangle's Y coordinates
                int y1 = y - radius;
                int y2 = y + radius;

                if (y1 < 0)
                {
                    y1 = 0;
                }
                if (y2 > heightM1)
                {
                    y2 = heightM1;
                }

                for (int x = 0; x < width; x++, ptr++)
                {
                    // rectangle's X coordinates
                    int x1 = x - radius;
                    int x2 = x + radius;

                    if (x1 < 0)
                    {
                        x1 = 0;
                    }
                    if (x2 > widthM1)
                    {
                        x2 = widthM1;
                    }

                    // *ptr = (byte) ( ( *ptr < (int) ( im.GetRectangleMeanUnsafe( x1, y1, x2, y2 ) * avgBrightnessPart ) ) ? 0 : 255 );
                    //*ptr = (byte) ( im.GetRectangleMeanUnsafe( x1, y1, x2, y2 ) * 255);
                    ptr[RGB.R] = ptr[RGB.R] = ptr[RGB.R] = (byte)(im.GetRectangleMeanUnsafe(x1, y1, x2, y2));
                }

                ptr += offset;
            }
        }
예제 #10
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="ScaleInvariantFeatureTranformKeypointDescriptor"/> class.
        /// </summary>
        ///
        internal ScaleInvariantFeatureTranformKeypointDescriptor(UnmanagedImage image,
                                                                 IntegralImage integral, ScaleInvariantFeatureTranformKeypointPattern pattern)
        {
            this.Extended            = false;
            this.IsOrientationNormal = true;
            this.IsScaleNormal       = true;
            this.Image    = image;
            this.Integral = integral;

            this._pattern = pattern;
        }
예제 #11
0
        /// <summary>
        /// Process the filter on the specified image.
        /// </summary>
        ///
        /// <param name="image">Source image data.</param>
        ///
        protected override unsafe void ProcessFilter(UnmanagedImage image)
        {
            // create integral image
            var im = IntegralImage.FromBitmap(image);

            var width    = image.Width;
            var height   = image.Height;
            var widthM1  = width - 1;
            var heightM1 = height - 1;

            var offset = image.Stride - width;
            var radius = this.windowSize / 2;

            var avgBrightnessPart = 1.0f - this.pixelBrightnessDifferenceLimit;

            var ptr = (byte *)image.ImageData.ToPointer( );

            for (var y = 0; y < height; y++)
            {
                // rectangle's Y coordinates
                var y1 = y - radius;
                var y2 = y + radius;

                if (y1 < 0)
                {
                    y1 = 0;
                }
                if (y2 > heightM1)
                {
                    y2 = heightM1;
                }

                for (var x = 0; x < width; x++, ptr++)
                {
                    // rectangle's X coordinates
                    var x1 = x - radius;
                    var x2 = x + radius;

                    if (x1 < 0)
                    {
                        x1 = 0;
                    }
                    if (x2 > widthM1)
                    {
                        x2 = widthM1;
                    }

                    *ptr = (byte)((*ptr < (int)(im.GetRectangleMeanUnsafe(x1, y1, x2, y2) * avgBrightnessPart)) ? 0 : 255);
                }

                ptr += offset;
            }
        }
예제 #12
0
        public void TestVertical1D()
        {
            double[] data =
            {
                1.0, 2.0, 3.0
            };
            Image         image          = new Image(1, data);
            IntegralImage integral_image = new IntegralImage(image);

            Assert.AreEqual(1.0, integral_image[0][0]);
            Assert.AreEqual(3.0, integral_image[1][0]);
            Assert.AreEqual(6.0, integral_image[2][0]);
        }
예제 #13
0
        public void TestHorizontal1D()
        {
            double[] data =
            {
                1.0, 2.0, 3.0
            };
            Image         image          = new Image(3, data);
            IntegralImage integral_image = new IntegralImage(image);

            Assert.AreEqual(1.0, integral_image[0][0]);
            Assert.AreEqual(3.0, integral_image[0][1]);
            Assert.AreEqual(6.0, integral_image[0][2]);
        }
예제 #14
0
        public IntegralImageTest()
        {
            UnmanagedImage uImage = UnmanagedImage.Create(10, 10, PixelFormat.Format8bppIndexed);

            for (int y = 0; y < 10; y++)
            {
                for (int x = 0; x < 10; x++)
                {
                    uImage.SetPixel(x, y, ((x + y) % 2 == 0) ? Color.FromArgb(0, 0, 0) : Color.FromArgb(1, 1, 1));
                }
            }

            integralImage = IntegralImage.FromBitmap(uImage);
        }
예제 #15
0
        public void TestStaticFilter5()
        {
            double[] data =
            {
                1.0, 2.0, 3.0,
                3.0, 4.0, 5.0,
                6.0, 7.0, 8.0,
            };
            Image         image          = new Image(3, data);
            IntegralImage integral_image = new IntegralImage(image);
            double        res            = Filter.Filter5(integral_image, 0, 0, 3, 3, Filter.Subtract);

            Assert.AreEqual(-15.0, res, TestsHelper.EPS); // 3+4+5 - (1+2+3) - (6+7+8)
        }
        public List <ScaleInvariantFeatureTranformKeypoint> ProcessImage(UnmanagedImage image)
        {
            // check image format
            if (
                (image.PixelFormat != PixelFormat.Format8bppIndexed) &&
                (image.PixelFormat != PixelFormat.Format24bppRgb) &&
                (image.PixelFormat != PixelFormat.Format32bppRgb) &&
                (image.PixelFormat != PixelFormat.Format32bppArgb)
                )
            {
                throw new UnsupportedImageFormatException("Unsupported pixel format of the source image.");
            }

            // make sure we have grayscale image
            if (image.PixelFormat == PixelFormat.Format8bppIndexed)
            {
                _grayImage = image;
            }
            else
            {
                // create temporary grayscale image
                _grayImage = Grayscale.CommonAlgorithms.BT709.Apply(image);
            }


            // 1. Extract corners points from the image.
            List <IntPoint> corners = Detector.ProcessImage(_grayImage);

            List <ScaleInvariantFeatureTranformKeypoint> features = new List <ScaleInvariantFeatureTranformKeypoint>();

            for (int i = 0; i < corners.Count; i++)
            {
                features.Add(new ScaleInvariantFeatureTranformKeypoint(corners[i].X, corners[i].Y));
            }


            // 2. Compute the integral for the given image
            _integral = IntegralImage.FromBitmap(_grayImage);


            // 3. Compute feature descriptors if required
            _descriptor = null;
            if (_featureType != ScaleInvariantFeatureTranformKeypointDescriptorType.None)
            {
                _descriptor = GetDescriptor();
                _descriptor.Compute(features);
            }

            return(features);
        }
예제 #17
0
        public void TestFilter0()
        {
            Image image = new Image(2, 2);

            image.Set(0, 0, 0.0);
            image.Set(0, 1, 1.0);
            image.Set(1, 0, 2.0);
            image.Set(1, 1, 3.0);

            Filter        flt1           = new Filter(0, 0, 1, 1);
            IntegralImage integral_image = new IntegralImage(image);

            Assert.AreEqual(0.0, flt1.Apply(integral_image, 0), TestsHelper.EPS);
            Assert.AreEqual(1.0986123, flt1.Apply(integral_image, 1), TestsHelper.EPS);
        }
예제 #18
0
        public void TestBasic2D()
        {
            double[] data =
            {
                1.0, 2.0,
                3.0, 4.0,
            };
            Image         image          = new Image(2, data);
            IntegralImage integral_image = new IntegralImage(image);

            Assert.AreEqual(1.0, integral_image[0][0]);
            Assert.AreEqual(3.0, integral_image[0][1]);
            Assert.AreEqual(4.0, integral_image[1][0]);
            Assert.AreEqual(10.0, integral_image[1][1]);
        }
예제 #19
0
        public void DescribeInterestPoints(List<InterestingPoint> ipts, bool upright, bool extended, IntegralImage img)
        {
            if (ipts.Count == 0) return;
            this.img = img;

            foreach (InterestingPoint ip in ipts)
            {
                // determine descriptor size
                if (extended) ip.DescriptorLength = 128;
                else ip.DescriptorLength = 64;

                // if we want rotation invariance get the orientation
                if (!upright) GetOrientation(ip);

                // Extract SURF descriptor
                GetDescriptor(ip, upright, extended);
            }
        }
예제 #20
0
        protected override unsafe void ProcessFilter(UnmanagedImage image)
        {
            IntegralImage image2 = IntegralImage.FromBitmap(image);
            int           width  = image.Width;
            int           height = image.Height;
            int           num3   = width - 1;
            int           num4   = height - 1;
            int           num5   = image.Stride - width;
            int           num6   = this.windowSize / 2;
            float         num7   = 1f - this.pixelBrightnessDifferenceLimit;
            byte *        numPtr = (byte *)image.ImageData.ToPointer();

            for (int i = 0; i < height; i++)
            {
                int num9  = i - num6;
                int num10 = i + num6;
                if (num9 < 0)
                {
                    num9 = 0;
                }
                if (num10 > num4)
                {
                    num10 = num4;
                }
                int num11 = 0;
                while (num11 < width)
                {
                    int num12 = num11 - num6;
                    int num13 = num11 + num6;
                    if (num12 < 0)
                    {
                        num12 = 0;
                    }
                    if (num13 > num3)
                    {
                        num13 = num3;
                    }
                    numPtr[0] = (numPtr[0] < ((int)(image2.GetRectangleMeanUnsafe(num12, num9, num13, num10) * num7))) ? ((byte)0) : ((byte)0xff);
                    num11++;
                    numPtr++;
                }
                numPtr += num5;
            }
        }
예제 #21
0
        protected unsafe override void ProcessFilter(UnmanagedImage image)
        {
            IntegralImage integralImage = IntegralImage.FromBitmap(image);
            int           width         = image.Width;
            int           height        = image.Height;
            int           num           = width - 1;
            int           num2          = height - 1;
            int           num3          = image.Stride - width;
            int           num4          = windowSize / 2;
            float         num5          = 1f - pixelBrightnessDifferenceLimit;
            byte *        ptr           = (byte *)image.ImageData.ToPointer();

            for (int i = 0; i < height; i++)
            {
                int num6 = i - num4;
                int num7 = i + num4;
                if (num6 < 0)
                {
                    num6 = 0;
                }
                if (num7 > num2)
                {
                    num7 = num2;
                }
                int num8 = 0;
                while (num8 < width)
                {
                    int num9  = num8 - num4;
                    int num10 = num8 + num4;
                    if (num9 < 0)
                    {
                        num9 = 0;
                    }
                    if (num10 > num)
                    {
                        num10 = num;
                    }
                    *ptr = (byte)((*ptr >= (int)(integralImage.GetRectangleMeanUnsafe(num9, num6, num10, num7) * num5)) ? 255 : 0);
                    num8++;
                    ptr++;
                }
                ptr += num3;
            }
        }
예제 #22
0
        /// <summary>
        /// Process the filter on the specified image.
        ///
        /// </summary>
        /// <param name="image">Source image data.</param>
        protected override unsafe void ProcessFilter(UnmanagedImage image)
        {
            IntegralImage integralImage = IntegralImage.FromBitmap(image);
            int           width         = image.Width;
            int           height        = image.Height;
            int           num1          = width - 1;
            int           num2          = height - 1;
            int           num3          = image.Stride - width;
            int           num4          = _windowSize / 2;
            float         num5          = 1f - _pixelBrightnessDifferenceLimit;
            byte *        numPtr        = (byte *)image.ImageData.ToPointer();

            for (int index = 0; index < height; ++index)
            {
                int y1 = index - num4;
                int y2 = index + num4;
                if (y1 < 0)
                {
                    y1 = 0;
                }
                if (y2 > num2)
                {
                    y2 = num2;
                }
                int num6 = 0;
                while (num6 < width)
                {
                    int x1 = num6 - num4;
                    int x2 = num6 + num4;
                    if (x1 < 0)
                    {
                        x1 = 0;
                    }
                    if (x2 > num1)
                    {
                        x2 = num1;
                    }
                    *numPtr = (int)*numPtr < (int)((double)integralImage.GetRectangleMeanUnsafe(x1, y1, x2, y2) * (double)num5) ? (byte)0 : byte.MaxValue;
                    ++num6;
                    ++numPtr;
                }
                numPtr += num3;
            }
        }
예제 #23
0
        public void TestStaticFilter2()
        {
            double[] data =
            {
                1.0, 2.0, 3.0,
                3.0, 4.0, 5.0,
                6.0, 7.0, 8.0,
            };
            Image         image          = new Image(3, data);
            IntegralImage integral_image = new IntegralImage(image);
            double        res;

            res = Filter.Filter2(integral_image, 0, 0, 2, 1, Filter.Subtract);
            Assert.AreEqual(2.0, res, TestsHelper.EPS); // 3 - 1
            res = Filter.Filter2(integral_image, 0, 0, 2, 2, Filter.Subtract);
            Assert.AreEqual(4.0, res, TestsHelper.EPS); // 3+4 - 1+2
            res = Filter.Filter2(integral_image, 0, 0, 2, 3, Filter.Subtract);
            Assert.AreEqual(6.0, res, TestsHelper.EPS); // 3+4+5 - 1+2+3
        }
예제 #24
0
        public void TestStaticFilter3()
        {
            double[] data =
            {
                1.0, 2.1, 3.4,
                3.1, 4.1, 5.1,
                6.0, 7.1, 8.0,
            };
            Image         image          = new Image(3, data);
            IntegralImage integral_image = new IntegralImage(image);
            double        res;

            res = Filter.Filter3(integral_image, 0, 0, 2, 2, Filter.Subtract);
            Assert.AreEqual(0.1, res, TestsHelper.EPS); // 2.1+3.1 - 1+4.1
            res = Filter.Filter3(integral_image, 1, 1, 2, 2, Filter.Subtract);
            Assert.AreEqual(0.1, res, TestsHelper.EPS); // 4+8 - 5+7
            res = Filter.Filter3(integral_image, 0, 1, 2, 2, Filter.Subtract);
            Assert.AreEqual(0.3, res, TestsHelper.EPS); // 2.1+5.1 - 3.4+4.1
        }
        public void TestCalculateSubfingerprint()
        {
            Image image = new Image(2, 2);

            image[0, 0] = 0.0;
            image[0, 1] = 1.0;
            image[1, 0] = 2.0;
            image[1, 1] = 3.0;

            Classifier[] classifiers =
            {
                new Classifier(new Filter(0, 0, 1, 1), new Quantizer(0.01, 1.01, 1.5)),
            };
            FingerprintCalculator calculator = new FingerprintCalculator(classifiers);

            IntegralImage integral_image = new IntegralImage(image);

            Assert.AreEqual(TestsHelper.GrayCode(0), calculator.CalculateSubfingerprint(integral_image, 0));
            Assert.AreEqual(TestsHelper.GrayCode(2), calculator.CalculateSubfingerprint(integral_image, 1));
        }
예제 #26
0
            public float Compute(ImageDataPoint <float> point)
            {
                if (point.ImageID != _currentID)
                {
                    _currentID = point.ImageID;
                    if (point.Image.IsIntegral || DecisionTree <ImageDataPoint <float>, float[]> .IsBuilding)
                    {
                        _integralImage = point.Image;
                    }
                    else
                    {
                        _integralImage = IntegralImage.ComputeFloat <FloatArrayHandler>(point.Image);
                    }
                }
                int   row    = point.Row;
                int   column = point.Column;
                float sum    = _integralImage.ComputeRectangleSum(row, column, _channel, _rect);

                Debug.Assert(!float.IsNaN(sum), "Rectangle sum is NaN");
                return(sum);
            }
예제 #27
0
        public void Compute(IntegralImage image)
        {
            int   b = (Size - 1) / 2 + 1;
            int   c = Size / 3;
            int   w = Size;
            float inv = 1f / (w * w);
            float Dxx, Dyy, Dxy;

            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    // Get the image coordinates
                    int i = y * Step;
                    int j = x * Step;

                    // Compute response components
                    Dxx = ((int)image.GetRectangleSum(j - b, i - c + 1, j - b + w - 1, i - c + 2 * c - 1)
                           - (int)image.GetRectangleSum(j - c / 2, i - c + 1, j - c / 2 + c - 1, i - c + 2 * c - 1) * 3);

                    Dyy = ((int)image.GetRectangleSum(j - c + 1, i - b, j - c + 2 * c - 1, i - b + w - 1)
                           - (int)image.GetRectangleSum(j - c + 1, i - c / 2, j - c + 2 * c - 1, i - c / 2 + c - 1) * 3);

                    Dxy = ((int)image.GetRectangleSum(j + 1, i - c, j + c, i - 1)
                           + (int)image.GetRectangleSum(j - c, i + 1, j - 1, i + c)
                           - (int)image.GetRectangleSum(j - c, i - c, j - 1, i - 1)
                           - (int)image.GetRectangleSum(j + 1, i + 1, j + c, i + c));

                    // Normalize the filter responses with respect to their size
                    Dxx *= inv / 255f;
                    Dyy *= inv / 255f;
                    Dxy *= inv / 255f;

                    // Get the determinant of Hessian response & laplacian sign
                    Responses[y, x] = (Dxx * Dyy) - (0.9f * 0.9f * Dxy * Dxy);
                    Laplacian[y, x] = (Dxx + Dyy) >= 0 ? 1 : 0;
                }
            }
        }
예제 #28
0
        public void TestStaticFilter1()
        {
            double[] data =
            {
                1.0, 2.1, 3.4,
                3.1, 4.1, 5.1,
                6.0, 7.1, 8.0
            };
            Image         image          = new Image(3, data);
            IntegralImage integral_image = new IntegralImage(image);
            double        res;

            res = Filter.Filter1(integral_image, 0, 0, 1, 1, Filter.Subtract);
            Assert.AreEqual(1.0 - 0.0, res);
            res = Filter.Filter1(integral_image, 1, 1, 1, 1, Filter.Subtract);
            Assert.AreEqual(4.1 - 0.0, res);
            res = Filter.Filter1(integral_image, 0, 0, 1, 2, Filter.Subtract);
            Assert.AreEqual(2.1 - 1.0, res);
            res = Filter.Filter1(integral_image, 0, 0, 2, 2, Filter.Subtract);
            Assert.AreEqual((2.1 + 4.1) - (1.0 + 3.1), res);
            res = Filter.Filter1(integral_image, 0, 0, 3, 2, Filter.Subtract);
            Assert.AreEqual((2.1 + 4.1 + 7.1) - (1.0 + 3.1 + 6.0), res);
        }
예제 #29
0
        private void btnRunSurf_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.ShowDialog();
            string pathToFile = openFileDialog.FileName;

            Stopwatch watch = new Stopwatch();

            watch.Start();

            try
            {
                // Load an Image
                Bitmap img = new Bitmap(pathToFile);
                pbMainPicture.Image = img;

                // Create Integral Image
                IntegralImage iimg = IntegralImage.FromImage(img);

                // Extract the interest points
                ipts = FastHessian.getIpoints(0.0002f, 5, 2, iimg);

                // Describe the interest points
                SurfDescriptor.DecribeInterestPoints(ipts, false, false, iimg);

                // Draw points on the image
                PaintSURF(img, ipts);
            }
            catch
            {
            }

            watch.Stop();
            this.Text = "DemoSURF - Elapsed time: " + watch.Elapsed +
                        " for " + ipts.Count + "points";
        }
예제 #30
0
        public void TestArea()
        {
            double[] data =
            {
                1.0, 2.0, 3.0,
                4.0, 5.0, 6.0,
                7.0, 8.0, 9.0,
            };

            Image         image          = new Image(3, data);
            IntegralImage integral_image = new IntegralImage(image);

            Assert.AreEqual((1.0), integral_image.Area(0, 0, 0, 0));
            Assert.AreEqual((1.0 + 4.0), integral_image.Area(0, 0, 1, 0));
            Assert.AreEqual((1.0 + 4.0 + 7.0), integral_image.Area(0, 0, 2, 0));

            Assert.AreEqual((1.0) + (2.0), integral_image.Area(0, 0, 0, 1));
            Assert.AreEqual((1.0 + 4.0) + (2.0 + 5.0), integral_image.Area(0, 0, 1, 1));
            Assert.AreEqual((1.0 + 4.0 + 7.0) + (2.0 + 5.0 + 8.0), integral_image.Area(0, 0, 2, 1));

            Assert.AreEqual((2.0), integral_image.Area(0, 1, 0, 1));
            Assert.AreEqual((2.0 + 5.0), integral_image.Area(0, 1, 1, 1));
            Assert.AreEqual((2.0 + 5.0 + 8.0), integral_image.Area(0, 1, 2, 1));
        }
예제 #31
0
 public SpeededUpRobustFeaturesDescriptor(IntegralImage integralImage)
 {
     _integral = integralImage;
 }
예제 #32
0
 public static void DecribeInterestPoints(List<InterestingPoint> ipts, bool upright, bool extended, IntegralImage img)
 {
     SurfDescriptor des = new SurfDescriptor();
     des.DescribeInterestPoints(ipts, upright, extended, img);
 }
예제 #33
0
 public int Classify(IntegralImage image, int offset)
 {
     double value = m_filter.Apply(image, offset);
     return m_quantizer.Quantize(value);
 }
        /// <summary>
        ///   Initializes a new instance of the <see cref="FastRetinaKeypointDescriptor"/> class.
        /// </summary>
        /// 
        internal FastRetinaKeypointDescriptor(UnmanagedImage image,
            IntegralImage integral, FastRetinaKeypointPattern pattern)
        {
            this.Extended = false;
            this.IsOrientationNormal = true;
            this.IsScaleNormal = true;
            this.Image = image;
            this.Integral = integral;

            this.pattern = pattern;
        }
 /// <summary>
 ///   Initializes a new instance of the <see cref="SpeededUpRobustFeaturesDescriptor"/> class.
 /// </summary>
 /// 
 /// <param name="integralImage">
 ///   The integral image which is the source of the feature points.
 /// </param>
 /// 
 public SpeededUpRobustFeaturesDescriptor(IntegralImage integralImage)
 {
     this.integral = integralImage;
 }
예제 #36
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="SurfDescriptor"/> class.
 /// </summary>
 /// 
 /// <param name="integralImage">
 ///   The integral image which is the source of the feature points.
 /// </param>
 /// 
 public SurfDescriptor(IntegralImage integralImage)
 {
     this.integral = integralImage;
 }