Code base obscuration (for images) 1.0
It implements different obscuration methods on portable images (.pgm and .ppm)
Loading...
Searching...
No Matches
obscurationPPM.hpp
Go to the documentation of this file.
1
10
11#include <iostream>
12#include <vector>
13#include <random>
14#include <bitset>
15#include <cstring>
16#include <fstream>
17
18#ifndef STAGE_IMAGE_FUNCTIONS_H
19#define STAGE_IMAGE_FUNCTIONS_H
20
21#define M_PI 3.14159265358979323846
22
31{
32public:
33 //====================== Interpolate ======================//
34
47 static int interpolate_color(int p11, int p21, int p12, int p22, float dx, float dy);
48
60 static void interpolate_bilinear(ImageBase &image, int &valR, int &valG, int &valB, float i, float j);
61
69 static void bilinearRedim299(ImageBase &image, ImageBase &o_image);
70
71 //====================== Histogram ======================//
72
82 static void computeColorHist(ImageBase &image, int histR[256], int histG[256], int histB[256]);
83
91 static void compareImagesByHist(ImageBase &image1, ImageBase &image2);
92
93 //====================== Gaussian blurring ======================//
94
103 static void generateGaussianKernel(std::vector<std::vector<float>> &kernel, int size, float sigma);
104
114 static void gaussianBlur(ImageBase &image, ImageBase &o_image, int kernelSize, float sigma);
115
116 //====================== Average blurring ======================//
117
126 static void averageBlurring(ImageBase &image, ImageBase &o_image, int regionSize);
127
135 static void newAverageBlurring(ImageBase &image, std::vector<ImageBase> &o_images);
136
137 //====================== Scrambling ======================//
138
150 static void areaScrambling(ImageBase &image, ImageBase &o_image, int start_i, int start_j, int area_h, int area_w);
151
161 static void scrambling(ImageBase &image, ImageBase &o_image, int regionHeight, int regionWidth);
162
163 //====================== Averager ======================//
164
176 static void areaAverager(ImageBase &image, ImageBase &o_image, int start_i, int start_j, int area_h, int area_w);
177
187 static void averageByRegion(ImageBase &image, ImageBase &o_image, int regionHeight, int regionWidth);
188
189 //====================== Encryption ======================//
190
199 static void selectiveProgressiveEncryption(ImageBase &image, ImageBase o_images[8], bool MSBtoLSB);
200
208 static void selectiveIndividualEncryption(ImageBase &image, ImageBase o_images[8]);
209
219 static void selectiveGroupEncryption(ImageBase &image, ImageBase &o_image, int bitsGroup[8], int groupSize);
220
229 static double computePSNR(ImageBase &image1, ImageBase &image2);
230
241 static void computePSNRforAllAlterations(std::vector<double> &PSNRArray, const char *baseName, int i_min, int i_max, int step);
242
250 static void writeDataOnTxt(std::vector<double> &data, std::string filename);
251
259 static void RGB2GREY(ImageBase &imColor, ImageBase &imGrey);
260
268 static double computeImageMean(ImageBase &image);
269
278 static double computeSSIM(ImageBase &image1, ImageBase &image2);
279};
280
281#endif // STAGE_IMAGE_FUNCTIONS_H
Base class containing some basic functionalities for images.
This class is a base class for images. It provides some basic functionalities for images.
Definition ImageBase.hpp:21
This class contains common and useful methods for obscuring images.
Definition obscurationCommon.hpp:28
This class implements various image obscuration techniques for the PPM image format.
Definition obscurationPPM.hpp:31
static void compareImagesByHist(ImageBase &image1, ImageBase &image2)
Compares the histograms of two images.
Definition obscurationPPM.cpp:82
static void areaScrambling(ImageBase &image, ImageBase &o_image, int start_i, int start_j, int area_h, int area_w)
Applies area scrambling to an image using a given start position and area size.
Definition obscurationPPM.cpp:246
static void bilinearRedim299(ImageBase &image, ImageBase &o_image)
Resizes an image to 299x299 pixels using bilinear interpolation.
Definition obscurationPPM.cpp:42
static void computeColorHist(ImageBase &image, int histR[256], int histG[256], int histB[256])
Computes the histograms of the red, green, and blue color components of an image.
Definition obscurationPPM.cpp:65
static void areaAverager(ImageBase &image, ImageBase &o_image, int start_i, int start_j, int area_h, int area_w)
Applies area averaging to an image using a given start position and area size.
Definition obscurationPPM.cpp:298
static void selectiveGroupEncryption(ImageBase &image, ImageBase &o_image, int bitsGroup[8], int groupSize)
Applies selective group encryption to an image using a given bit group and group size.
Definition obscurationPPM.cpp:408
static double computePSNR(ImageBase &image1, ImageBase &image2)
Computes the peak signal-to-noise ratio (PSNR) between two images.
Definition obscurationPPM.cpp:437
static void interpolate_bilinear(ImageBase &image, int &valR, int &valG, int &valB, float i, float j)
Interpolates the color values of a pixel at a given position in an image using bilinear interpolation...
Definition obscurationPPM.cpp:31
static void writeDataOnTxt(std::vector< double > &data, std::string filename)
Writes data to a text file.
Definition obscurationPPM.cpp:476
static void generateGaussianKernel(std::vector< std::vector< float > > &kernel, int size, float sigma)
Generates a Gaussian kernel for image blurring.
Definition obscurationPPM.cpp:99
static void selectiveIndividualEncryption(ImageBase &image, ImageBase o_images[8])
Applies selective individual encryption to an image.
Definition obscurationPPM.cpp:378
static double computeSSIM(ImageBase &image1, ImageBase &image2)
Computes the structural similarity index (SSIM) between two images.
Definition obscurationPPM.cpp:510
static void averageByRegion(ImageBase &image, ImageBase &o_image, int regionHeight, int regionWidth)
Applies average by region to an image using a given region size.
Definition obscurationPPM.cpp:319
static void scrambling(ImageBase &image, ImageBase &o_image, int regionHeight, int regionWidth)
Applies scrambling to an image using a given region size.
Definition obscurationPPM.cpp:275
static void newAverageBlurring(ImageBase &image, std::vector< ImageBase > &o_images)
Applies new average blurring to an image using a given number of images.
Definition obscurationPPM.cpp:185
static void averageBlurring(ImageBase &image, ImageBase &o_image, int regionSize)
Applies average blurring to an image using a given region size.
Definition obscurationPPM.cpp:160
static void gaussianBlur(ImageBase &image, ImageBase &o_image, int kernelSize, float sigma)
Applies Gaussian blurring to an image using a given kernel size and standard deviation.
Definition obscurationPPM.cpp:120
static void computePSNRforAllAlterations(std::vector< double > &PSNRArray, const char *baseName, int i_min, int i_max, int step)
Computes the PSNR for all alterations in a given range.
Definition obscurationPPM.cpp:458
static void RGB2GREY(ImageBase &imColor, ImageBase &imGrey)
Converts an RGB image to grayscale.
Definition obscurationPPM.cpp:494
static double computeImageMean(ImageBase &image)
Computes the mean value of an image.
Definition obscurationPPM.cpp:501
static void selectiveProgressiveEncryption(ImageBase &image, ImageBase o_images[8], bool MSBtoLSB)
Applies selective progressive encryption to an image using a given encryption direction.
Definition obscurationPPM.cpp:342
static int interpolate_color(int p11, int p21, int p12, int p22, float dx, float dy)
Interpolates the color value of a pixel at a given position using bilinear interpolation.
Definition obscurationPPM.cpp:21
Header of super class containing common and useful methods for obscuring pgm and ppm images.