コード例 #1
0
ファイル: Dwt.cs プロジェクト: 238379/watermark_analyzer
        public EffectiveBitmap ProcessHaar(EffectiveBitmap image, bool isRevert, int layers)
        {
            var haarColors = new HaarColor[image.Height, image.Width];

            for (int i = 0; i < image.Height; i++)
            {
                for (int j = 0; j < image.Width; j++)
                {
                    var color     = image.GetPixel(i, j);
                    var haarColor = new HaarColor(color);
                    haarColors[j, i] = haarColor;
                }
            }

            if (!isRevert)
            {
                FWT(haarColors, layers);
            }
            else
            {
                IWT(haarColors, layers);
            }

            var haarBitmap = EffectiveBitmap.Create(image.Width, image.Height, image.Depth, (i, j) =>
            {
                var haarColor = haarColors[j, i];
                return(haarColor.GetPixelInfo());
            });

            return(haarBitmap);
        }
コード例 #2
0
        public override double CalculateDifference(EffectiveBitmap bitmap)
        {
            bitmap = bitmap.Resize(target.Width, target.Height);

            double differenceSum = 0;

            target.RunOnEveryPixel((x, y) =>
            {
                var p1         = target.GetPixel(x, y);
                var p2         = bitmap.GetPixel(x, y);
                differenceSum += Math.Abs(p1.R - p2.R) + Math.Abs(p1.G - p2.G) + Math.Abs(p1.B - p2.B);
            });

            return(differenceSum);
        }
コード例 #3
0
        private EffectiveBitmap Watermark(EffectiveBitmap original, EffectiveBitmap watermark)
        {
            var simplifiedWatermark = PreprocessToSimplifiedWatermark(watermark);

            return(EffectiveBitmap.Create(original.Width, original.Height, original.Depth, (i, j) =>
            {
                var originalPixel = original.GetPixel(i, j);
                var watermarkPixel = simplifiedWatermark.GetPixel(i, j);

                var divider = (int)Math.Pow(2, parameters.BitsForWatermark);
                var r = (byte)(Math.Clamp(originalPixel.R - originalPixel.R % divider + watermarkPixel.R, 0, 255));
                var g = (byte)(Math.Clamp(originalPixel.G - originalPixel.G % divider + watermarkPixel.G, 0, 255));
                var b = (byte)(Math.Clamp(originalPixel.B - originalPixel.B % divider + watermarkPixel.B, 0, 255));

                return new PixelInfo(r, g, b);
            }));
        }