Example #1
0
 protected override void InitializeDecoding(string src, int passHash, int lsbIndicator)
 {
     base.InitializeDecoding(src, passHash, lsbIndicator);
     var filter = new Laplace(Bitmap, LsbIndicator, 8);
     IDictionary<Pixel, int> filtered = new Dictionary<Pixel, int>();
     for (var x = 0; x < Bitmap.Width; x++)
     {
         for (var y = 0; y < Bitmap.Height; y++)
         {
             filtered.Add(new Pixel(x, y), filter.GetValue(x, y));
         }
     }
     mLaplaceValues = filtered.OrderByDescending(key => key.Value);
 }
        protected override double Calculation(LockBitmap originalBmp, LockBitmap steganoBmp)
        {
            var origFiltered = new Laplace(originalBmp, 0, 8);
            var stegoFiltered = new Laplace(steganoBmp, 0, 8);
            var originalDiff = 0.0;
            var totalDiff = 0.0;

            for (var y = 0; y < originalBmp.Height; y++)
            {
                for (var x = 0; x < originalBmp.Width; x++)
                {
                    //TODO Shouldnt that be the other direction? First TOTAL and second ORIGINAL?
                    originalDiff += Math.Pow(origFiltered.GetValue(x, y) - stegoFiltered.GetValue(x, y), 2);
                    totalDiff += Math.Pow(origFiltered.GetValue(x, y), 2);
                }
            }

            return originalDiff/totalDiff;
        }
Example #3
0
        /**
         * Gets the laplace graph of an image.  The image
         * is assumed to be colour, no negative values will
         * result.
         *
         * @param image The image to get the graph of.
         * @return The graph of the image.
         */
        public static double[][] GetGraph(LockBitmap image)
        {
            var filter = new Laplace(image, 0, 8);

            //filter the image
            var fparray =
                new FilteredPixel[image.Width*image.Height];
            for (var i = 0; i < image.Width; i++)
            {
                for (var j = 0; j < image.Height; j++)
                {
                    fparray[i*image.Height + j] =
                        new FilteredPixel(i, j,
                            Math.Abs(filter.GetValue(i, j)));
                }
            }

            //sort the filter results
            //is in ascending order - low at start, high at end
            Array.Sort(fparray, new FpComparator());

            //now for each individual filter result, we count how many we have

            //first find out how many different values we have
            var numdistinct = 1;
            for (var i = 1; i < fparray.Length; i++)
            {
                if (fparray[i].FilterValue != fparray[i - 1].FilterValue)
                {
                    numdistinct++;
                }
            }

            //now we create an array to hold the filter values and their counts
            //var results = new double[numdistinct][2];
            var results = new double[numdistinct][];
            for (var i = 0; i < results.Length; i++)
            {
                results[i] = new double[2];
            }
            results[0][0] = fparray[0].FilterValue;
            results[0][1] = 1;
            var k = 0;

            //now we fill up the array
            foreach (var t in fparray)
            {
                if (results[k][0] != t.FilterValue)
                {
                    k++;
                    results[k][0] = t.FilterValue;
                    results[k][1] = 1;
                }
                else
                {
                    results[k][1]++;
                }
            }

            //now normalise the graph
            foreach (var t in results)
            {
                t[1] = t[1]/fparray.Length;
            }

            //graph produced, return results
            return results;
        }
Example #4
0
 private void GenerateShips()
 {
     var filter = new Laplace(Bitmap, LsbIndicator, 8);
     IDictionary<Pixel, int> filtered = new Dictionary<Pixel, int>();
     for (var x = 0; x < Bitmap.Width; x++)
     {
         for (var y = 0; y < Bitmap.Height; y++)
         {
             filtered.Add(new Pixel(x, y), filter.GetValue(x, y));
         }
     }
     var ordered = filtered.OrderByDescending(key => key.Value);
     //TODO: dynamic maybe? Top 100
     mShips = new HashSet<Pixel>(ordered.Select((x, y) => x.Key).Take(50));
 }