Esempio n. 1
0
        /// <summary>
        /// compute dct robust image hash
        /// </summary>
        /// <param name="image">An image to compute DCT hash.</param>
        /// <returns>hash of type ulong</returns>
        public static ulong ComputeDctHash(IByteImage image)
        {
            FloatImage img = image.Convolve(new FloatImage(7, 7, 1));

            FloatImage resized  = img.Resize(32, 32);
            FloatImage coeff    = _DctMatrix ?? (_DctMatrix = CreateDctMatrix(32));
            FloatImage dctImage = coeff.MatrixMultiply(resized).MatrixMultiply(coeff, isTransposed: true);

            float median = GetMedianOf64(dctImage);

            ulong r = 0ul;

            for (int y = 0; y < 8; y++)
            {
                for (int x = 0; x < 8; x++)
                {
                    r |= dctImage[x + 1, y + 1] > median ? (1ul << (x + 8 * y)) : 0;
                }
            }

            return(r);
        }