Highly Nonlinear Approximations for Sparse Signal Representation

Logo EPSRC

EIFS Example

Download the MATLAB code for this example here.

Example details.

% EIFSExample This example demonstrates the use of the Encrypted Image Folding Software (EIFS)
% by reproducing the example in the paper:
%
%  [1]  Sparsity and `something else': An Approach to  Encrypted Image Folding, by James
%       Bowley and Laura Rebollo-Neira
%
% The image is a 256 x 256 pixel grey level intensity photo of Bertrand Russell. The EIF
% method is applied twice, using two different approaches for the representation:
%  1) The standard DCT in 2D by disregarding the smallest coefficients.
%  2) The RDCDB dictionary - composed of Discrete Cosine (redundancy 2) plus Dirac Basis
%     and a dedicated implementation of the Orthogonal Matching Pursuit (OMP) method for
%     these dictionaries.
% For a much faster implementation of 2) please use the C++ implementation of OMP in 2D
% (OMP2D).
% For this:
%   i) compile the OMP2.cpp file and move it to EIFS/Approximation_Routines folder, all this
%   can be done simply by running the script CompileOMP in the EIFS/Mex_Files
%   subdirectory
%   ii) replace 'RDCTDB' with 'RDCTDBMex' in method 2).
% For each method, the unfolding operation is performed twice, using the correct and
% incorrect private keys. The corresponding results shown in Figures 1 and 2.

clear all;
clc;
close all;
% Setting the  dedicated inputs
imagePath = 'Ber256.jpg';
blockWidth = 8;
publicKey = 17;
rotate = 1;

Example using method 1) (DCT Approach for the image approximation)

method1 = 'DCT';
PSNR = 40.17;
privateKey1 = 987654321;
tic;
[mFoldedImage, cIndex, mImage, maxIntensity ] = ...
    FoldImage(imagePath, method1, PSNR, blockWidth,publicKey,privateKey1,rotate);
%
saveImagePath1 = ['folded_', method1 '.jpg'];
SaveImage(mFoldedImage,saveImagePath1,maxIntensity);
% The folding was performed - The output  was saved as jpg file (folded_DCT.jpg)
% Recovering of the folded image starts - Requested inputs are
% cIndex (indices of the sparse representations) and Private key
privateKey2 = 123456789;
mLoadedImageDCT = double(imread(saveImagePath1));
%
mRecoveredImageDCT1 = ExpandImage(mLoadedImageDCT, cIndex, method1, blockWidth, publicKey, privateKey2, rotate);
timeDCT = toc;
PSNR1 = CalcPSNR(mImage,mRecoveredImageDCT1);
fprintf('PSNR in recovery with INCORRECT key: %.2f\n',PSNR1);
% The recovery was already attempted with an INCORRECT key (mRecoveredImageDCT1)
% Next the recovery  with the CORRECT Key
privateKey1 = 987654321;
mRecoveredImageDCT2 = ExpandImage(mLoadedImageDCT, cIndex, method1, blockWidth, publicKey, privateKey1, rotate);
PSNR2 = CalcPSNR(mImage,mRecoveredImageDCT2);
fprintf('PSNR in recovery with  the CORRECT key: %.2f\n',PSNR2);
FoldImage Routine Called
************************

Approximation Processing Ber256.jpg in blocks of 8x8 pixels using DCT
*********************************************************************
Approximation time: 0.47 seconds
PSNR in approximation: 40.3156 dB for an SR of 2.9113

Folding
*******
Time: 0.86 seconds

ExpandImage Routine Called
**************************
Time to seperate the embedded image (F) from the host image: 1.42 seconds
Time to reconstruct the rest of the image: 0.02 seconds
PSNR in recovery with INCORRECT key: 8.54

ExpandImage Routine Called
**************************
Time to seperate the embedded image (F) from the host image: 1.68 seconds
Time to reconstruct the rest of the image: 0.02 seconds
PSNR in recovery with  the CORRECT key: 40.11

Example using method 2) (RDCDB Approach for the image approximation)

method2 = 'RDCTDB';  % just change to RDCDBMex - For this OMP2D.cpp has to be compiled (see manual)
%
saveImagePath2 = ['folded_', method2 '.jpg'];
PSNR = 40.57;
privateKey1 = 987654321;
tic
[ mFoldedImage, cIndex, mImage, maxIntensity ] = ...
    FoldImage(imagePath, method2, PSNR, blockWidth,publicKey,privateKey1,rotate);
SaveImage(mFoldedImage,saveImagePath2,maxIntensity);
% The folding was performed  - The output  was saved as jpg file (folded_RDCTDB.jpg)
privateKey2 = 123456789;
mLoadedImageRDCTDB = double(imread(saveImagePath2));
mRecoveredImageRDCTDB1 = ExpandImage(mLoadedImageRDCTDB, cIndex, method2, blockWidth, publicKey, privateKey2, rotate);
PSNR1 = CalcPSNR(mImage,mRecoveredImageRDCTDB1);
fprintf('PSNR in recovery with an INCORRECT key: %.2f\n',PSNR1);
% The recovery was already attempted with an INCORRECT key (mRecoveredImageRDCTDB1)
timeRDCTDB = toc;
% Next the recover the images with the CORRECT Key
privateKey1 = 987654321;
mRecoveredImageRDCTDB2 = ExpandImage(mLoadedImageRDCTDB, cIndex, method2, blockWidth, publicKey, privateKey1, rotate);
PSNR2 = CalcPSNR(mImage,mRecoveredImageRDCTDB2);
fprintf('PSNR in recovery with the CORRECT key: %.2f\n',PSNR2);
FoldImage Routine Called
************************

Approximation Processing Ber256.jpg in blocks of 8x8 pixels using RDCTDB
************************************************************************
Approximation time: 6.2 seconds
Approximaton time can be reduced by up to 10 times by using the RDCDBMex option!
PSNR in approximation: 40.8833 dB for an SR of 4.5717

Folding
*******
Time: 0.51 seconds

ExpandImage Routine Called
**************************
Time to seperate the embedded image (F) from the host image: 1.30 seconds
Time to reconstruct the rest of the image: 0.02 seconds
PSNR in recovery with an INCORRECT key: 7.44

ExpandImage Routine Called
**************************
Time to seperate the embedded image (F) from the host image: 1.62 seconds
Time to reconstruct the rest of the image: 0.02 seconds
PSNR in recovery with the CORRECT key: 40.67

Example using method 2) (RDCDB Approach for the image approximation using OMP2D.mex)

method2 = 'RDCTDBMex';
FoldImage Routine Called
************************

Approximation Processing Ber256.jpg in blocks of 8x8 pixels using RDCTDBMex
***************************************************************************
Approximation time: 0.58 seconds
PSNR in approximation: 40.8833 dB for an SR of 4.5717

Folding
*******
Time: 0.47 seconds

ExpandImage Routine Called
**************************
Time to seperate the embedded image (F) from the host image: 1.30 seconds
Time to reconstruct the rest of the image: 0.02 seconds
PSNR in recovery with an INCORRECT key: 7.44

ExpandImage Routine Called
**************************
Time to seperate the embedded image (F) from the host image: 1.62 seconds
Time to reconstruct the rest of the image: 0.02 seconds
PSNR in recovery with the CORRECT key: 40.67

Display processing time;

PrintWithStars('Processing Time');
fprintf('Time for %s: %.2f seconds\n',method1,timeDCT);
fprintf('Time for %s: %.2f seconds\n',method2,timeRDCTDB);
Processing Time
***************
Time for DCT: 2.52 seconds
Time for RDCTDB: 7.43 seconds
Time for RDCTDBMex: 1.47 seconds

Display images

% Display of Figure 1 (DCT method)  containing: Image  and folded Image (top pictures)
%                         unfolded images with right and wrong keys (bottom pictures)
MakeFigures(mImage,mLoadedImageDCT,mRecoveredImageDCT1,mRecoveredImageDCT2,method1,maxIntensity);
% Display of Figure 2 (RDCDB method) containing: Image  and folded Image (top pictures)
%                         unfolded images with right and wrong keys (bottom pictures)
MakeFigures(mImage,mLoadedImageRDCTDB,mRecoveredImageRDCTDB1,mRecoveredImageRDCTDB2,method2,maxIntensity);