Steganography
A C++ Steganography tool which leverages the LSB and DCT embedding techniques
discrete_cosine_transform.hpp
1 /* This file is a part of "Steganography" a C++ steganography tool.
2 
3 Copyright (C) 2019 James Lee <jamesl33info@gmail.com>.
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 
18 #include <iostream>
19 #include <string>
20 #include <thread>
21 #include <tuple>
22 #include <vector>
23 #include <boost/filesystem.hpp>
24 #include <opencv2/core/core.hpp>
25 #include <opencv2/highgui/highgui.hpp>
26 #include <opencv2/imgproc/imgproc.hpp>
27 #include "steganography.hpp"
28 #include "exceptions.hpp"
29 
30 #ifndef DISCRETE_COSINE_TRANSFORM_HPP
31 #define DISCRETE_COSINE_TRANSFORM_HPP
32 
34 {
35  public:
42  explicit DiscreteCosineTransform(const boost::filesystem::path &image_path, int persistence) : Steganography(image_path)
43  {
44  this->persistence = persistence;
45  this->image_capacity = ((this->image.rows - 8) / 8) * ((this->image.cols - 8) / 8);
46 
47  // Convert the image to floating point and split the channels
48  this->image.convertTo(this->image, CV_32F);
49  cv::split(this->image, this->channels);
50  }
51 
58  void Encode(const boost::filesystem::path &payload_path);
59 
64  void Decode();
65 
66  private:
72  std::vector<cv::Mat> channels;
73 
81 
86  int image_capacity;
87 
98  void EncodeChunk(const int &start, std::vector<unsigned char>::iterator it, std::vector<unsigned char>::iterator en);
99 
107  void EncodeChunkLength(const int &start, const unsigned int &chunk_length);
108 
117  void DecodeChunk(const int start, std::vector<unsigned char>::iterator it, std::vector<unsigned char>::iterator en);
118 
127  unsigned int DecodeChunkLength(const int &start);
128 
138  void SwapCoefficients(cv::Mat *block, const int &value);
139 };
140 
141 #endif // DISCRETE_COSINE_TRANSFORM_HPP
boost::filesystem::path image_path
Definition: steganography.hpp:75
void SwapCoefficients(cv::Mat *block, const int &value)
Definition: discrete_cosine_transform.cpp:305
void DecodeChunk(const int start, std::vector< unsigned char >::iterator it, std::vector< unsigned char >::iterator en)
Definition: discrete_cosine_transform.cpp:221
int persistence
Definition: discrete_cosine_transform.hpp:80
void Decode()
Definition: discrete_cosine_transform.cpp:87
void EncodeChunk(const int &start, std::vector< unsigned char >::iterator it, std::vector< unsigned char >::iterator en)
Definition: discrete_cosine_transform.cpp:141
Definition: steganography.hpp:32
void Encode(const boost::filesystem::path &payload_path)
Definition: discrete_cosine_transform.cpp:22
Definition: discrete_cosine_transform.hpp:33
DiscreteCosineTransform(const boost::filesystem::path &image_path, int persistence)
Definition: discrete_cosine_transform.hpp:42
unsigned int DecodeChunkLength(const int &start)
Definition: discrete_cosine_transform.cpp:259
cv::Mat image
Definition: steganography.hpp:81
void EncodeChunkLength(const int &start, const unsigned int &chunk_length)
Definition: discrete_cosine_transform.cpp:181