public void Matrix_is_the_same_when_DCT_and_IDCT_are_aplied() { var matrix = convertToYCrCb(new double[,] { {26, 26, 26, 25, 25, 25, 26, 26}, {26, 26, 26, 25, 25, 25, 26, 26}, {26, 26, 26, 25, 25, 25, 26, 26}, {26, 26, 26, 25, 25, 25, 26, 26}, {26, 26, 26, 25, 25, 25, 26, 26}, {26, 26, 26, 25, 25, 25, 26, 26}, {26, 26, 26, 25, 25, 25, 26, 26}, {26, 26, 26, 25, 25, 25, 26, 26}, }); var expectedMatrix = MatrixUtil.Copy(matrix); DCT dct = new DCT(); TestHelper.PrintMatrix("DCT", matrix); dct.CalculateDCT(matrix); TestHelper.PrintMatrix("DCT", matrix); dct.CalculateIDCT(matrix); var doubleExpectedMatrix = convertToDouble(expectedMatrix); var doubleMatrix = convertToDouble(matrix); CollectionAssert.AreEquivalent(doubleExpectedMatrix, doubleMatrix); }
public void EmbedData(string path, byte[] message) { using (var stream = new StreamReader(path)) { var imageIo = new JpegImageIO(); var bytesRGB = imageIo.ReadRGBFromImage(stream.BaseStream); var matrix = YCrCb.Parse(bytesRGB); var dct = new DCT(); dct.CalculateDCT(matrix); Quantizer q = new Quantizer(); q.ApplyQuantization(matrix, Qf); var stego = new Steganography(); stego.HideMessage(matrix, message); q.ApplyInverseQuantization(matrix, Qf); dct.CalculateIDCT(matrix); string pathToSave = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path) + "_stego.jpg"); imageIo.WriteRGBToImage(pathToSave, RGB.Parse(matrix)); } }