Example demonstrating the use of the Self Contained Encrypted Image Folding Software routines on the image of the nebula NGC 2264
created at the European Southern Observatory (ESO).
Contents
close all;
clear all;
clc;
Approximation Variables
imagePath = 'red_astro.raw';
sApproxDetails.approxMethod = 'Dictionary';
sApproxDetails.sDetails = struct('name',{'DCT','Hats','Cubic','Cubic'...
},'parameters',{2,1,1,2});
algorithm = 'OMP2DMlW';
publicKey = 19;
save known_vars sApproxDetails algorithm publicKey
PSNRApprox = 39.565;
Image Approximation
sImageApprox = SImageApproxSCEIFS(imagePath,PSNRApprox,'greedy2D',algorithm,...
sApproxDetails);
approxTime = sImageApprox.approxTime
save summary_vars sImageApprox approxTime
MImageApproxSCEIFS Routine called
*********************************
Processing supplied image matrix using OMP2DMlW in blocks of 8 x 8
The image has an approximate maximum intensity of 65535
The SR of the approximation is 17.4554
PSNR: 42.50dB SSIM: 0.997
approxTime =
12.8038
Fold the image
privateKey = 1234567891;
startTime = clock;
mImageFolded = Folding(sImageApprox,sApproxDetails,publicKey,privateKey);
foldTime = etime(clock,startTime)
save('summary_vars','foldTime','mImageFolded','-append');
saveImagePath = 'SCEIF_folded.raw';
savePrecision = 'uint16';
SaveImageRaw(mImageFolded,saveImagePath,savePrecision);
clear all;
FoldApproxMl Routine Called
***************************
Folded Image: 88 x 1280 x 3 pixels, 11 x 160 blocks
Folding plain 1:- 2.53 seconds
Folding plain 2:- 2.48 seconds
Folding plain 3:- 2.49 seconds
FoldIndexGrey Routine Called
****************************
Folding Indexes:- 2.64 seconds
foldTime =
11.0083
Expand using the incorrect private key
loadImagePath = 'SCEIF_folded.raw';
savePrecision = 'uint16';
mImageLoaded = double(LoadImageRaw(loadImagePath,savePrecision));
privateKey = 1234567890;
sKnown = load('known_vars','sApproxDetails','publicKey');
[mImageRecovered1 cImage] = Expand(mImageLoaded,sKnown.sApproxDetails,...
sKnown.publicKey,privateKey);
save('summary_vars','mImageRecovered1','-append');
load('summary_vars','sImageApprox');
ShowFig2(RUint16(sImageApprox.mImage));
ShowFig3(uint16(mImageLoaded),...
cellfun(@RUint16,cImage,'UniformOutPut',0),...
uint16(mImageRecovered1),'Incorrect Private Key');
fprintf('\nQuality of the recovery (Original Image / Recovered Plain Text Image)\n')
fprintf('Incorrect Key: ');
PrintPSNR(sImageApprox.mImage,mImageRecovered1,sImageApprox.maxIntensity);
clear all;
ExpandIndexGrey Routine Called
******************************
Time to seperate the embedded image (F) from the host image: 2.63 seconds
ExpandImageRGB Routine Called
*****************************
Time to seperate the embedded image (F) from the host image: 3.04 seconds
Time to reconstruct the rest of the image: 1.48 seconds
Time to seperate the embedded image (F) from the host image: 4.24 seconds
Time to reconstruct the rest of the image: 0.76 seconds
Time to seperate the embedded image (F) from the host image: 2.70 seconds
Time to reconstruct the rest of the image: 0.76 seconds
Quality of the recovery (Original Image / Recovered Plain Text Image)
Incorrect Key: PSNR: 10.57dB
Expand using the correct private key
loadImagePath = 'SCEIF_folded.raw';
savePrecision = 'uint16';
mImageLoaded = double(LoadImageRaw(loadImagePath,savePrecision));
privateKey = 1234567891;
startTime = clock;
sKnown = load('known_vars','sApproxDetails','publicKey');
[mImageRecovered2 cImage] = Expand(mImageLoaded,sKnown.sApproxDetails,...
sKnown.publicKey,privateKey);
expandTime = etime(clock,startTime);
save('summary_vars','expandTime','mImageRecovered2','-append');
load('summary_vars','sImageApprox');
fprintf('\nQuality of the recovery (Original Image / Recovered Plain Text Image)\n')
fprintf('Correct Key: ');
PrintPSNRSSIM(sImageApprox.mImage,mImageRecovered2,sImageApprox.maxIntensity);
ShowFig3(uint16(mImageLoaded),...
cellfun(@RUint16,cImage,'UniformOutPut',0),...
uint16(mImageRecovered2),'Correct Private Key');
ExpandIndexGrey Routine Called
******************************
Time to seperate the embedded image (F) from the host image: 2.70 seconds
ExpandImageRGB Routine Called
*****************************
Time to seperate the embedded image (F) from the host image: 2.67 seconds
Time to reconstruct the rest of the image: 0.77 seconds
Time to seperate the embedded image (F) from the host image: 2.66 seconds
Time to reconstruct the rest of the image: 0.75 seconds
Time to seperate the embedded image (F) from the host image: 4.48 seconds
Time to reconstruct the rest of the image: 1.47 seconds
Quality of the recovery (Original Image / Recovered Plain Text Image)
Correct Key: PSNR: 42.50dB SSIM: 0.997
Print Summary
load summary_vars
fprintf('\n--------------------------------------------------------------------\n');
PrintWithStars('Summary');
fprintf('Quaility of the approximation (Original Image / Plain Text Image)\n')
PrintPSNRSSIM(sImageApprox.mImage,sImageApprox.mImageApprox,...
sImageApprox.maxIntensity);
fprintf('Quality of the recovery (Original Image / Recovered Plain Text Image)\n')
fprintf('Correct Key: ');
PrintPSNRSSIM(sImageApprox.mImage,mImageRecovered2,...
sImageApprox.maxIntensity);
fprintf('Incorrect Key: ');
PrintPSNR(sImageApprox.mImage,mImageRecovered1,sImageApprox.maxIntensity);
PrintWithStars('Image Dimensions');
fprintf('Plain Text Image\n');
fprintf('%4i x %4i x %1i\n',sImageApprox.y,sImageApprox.x,sImageApprox.z);
fprintf('Folded Image\n');
fprintf('%4i x %4i x %1i\n',size(mImageFolded));
PrintWithStars('Execution Times');
fprintf('Approximation: %.2f seconds (Building the Plain Text Image)\n',approxTime);
fprintf('Folding: %.2f seconds\n',foldTime);
fprintf('Expanding: %.2f seconds\n',expandTime);
fprintf('Total Time: %.2f seconds\n',approxTime+foldTime+expandTime);
fprintf('\n--------------------------------------------------------------------\n')
--------------------------------------------------------------------
Summary
*******
Quaility of the approximation (Original Image / Plain Text Image)
PSNR: 42.50dB SSIM: 0.997
Quality of the recovery (Original Image / Recovered Plain Text Image)
Correct Key: PSNR: 42.50dB SSIM: 0.997
Incorrect Key: PSNR: 10.57dB
Image Dimensions
****************
Plain Text Image
1464 x 1280 x 3
Folded Image
120 x 1280 x 3
Execution Times
***************
Approximation: 12.80 seconds (Building the Plain Text Image)
Folding: 11.01 seconds
Expanding: 17.12 seconds
Total Time: 40.93 seconds
--------------------------------------------------------------------