Example #1
0
        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);
        }
Example #2
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);
            }));
        }