public static Bitmap ExtractWatermarkUsingYiq(Bitmap targetImage, Bitmap watermarkImage) { var(redTarget, greenTarget, blueTarget) = BitmapUtils.GetRGB(targetImage); var(redWatermark, greenWatermark, blueWatermark) = BitmapUtils.GetRGB(watermarkImage); var(yTarget, iTarget, qTarget) = ColorConverter.ConvertRgbToYiq(redTarget, greenTarget, blueTarget); var grayscaleWatermark = TransformColorSpaceIntoGreyscale(redWatermark); return(ExtractDwtDctWatermark(iTarget, grayscaleWatermark)); }
private static Bitmap ConvertYiqColorToImage(double[,] y, double[,] i, double[,] q) { var width = y.GetLength(0); var height = y.GetLength(1); var watermarkedImage = new Bitmap(width, height); var(watermarkedR, watermarkedG, watermarkedB) = ColorConverter.ConvertYiqToRgb(y, i, q); for (var k = 0; k < height; k++) { for (var j = 0; j < width; j++) { var red = BitmapUtils.NormalizePixelValue(watermarkedR[k, j]); var green = BitmapUtils.NormalizePixelValue(watermarkedG[k, j]); var blue = BitmapUtils.NormalizePixelValue(watermarkedB[k, j]); watermarkedImage.SetPixel(k, j, Color.FromArgb(0, red, green, blue)); } } return(watermarkedImage); }