Clear Filters
Clear Filters

Is image type show any difference in calculating the time to encrypt or decrypt or encrypt and decrypt the image?

3 views (last 30 days)
Is image type show any difference in calculating the time to encrypt or decrypt or encrypt and decrypt the image? I am calculating the time complexity to encrypt and decrypt lena image of 5 types (lena.tif,lena.jpg,lena.png, lena.bmp, lena.gif)

Answers (2)

Walter Roberson
Walter Roberson on 6 May 2016
The time to decrypt an array is independent of how the array was derived, unless the "encryption" depends in subtle ways on the content of the image and the "information content" of some of the versions is different (e.g., JPEG probably has less information than the others.)
If you read in a JPEG lossy image, encrypt it, and write it out again as JPEG lossy, then do not be surprised if you cannot decrypt it properly afterwards.
Walter Roberson
Walter Roberson on 24 Oct 2017
Edited: Image Analyst on 24 Oct 2017
Do I understand correctly that you have something like,
impng = imresize( imread('lena.png'), [128 128]);
imtif = imresize( imread('lena.tif'), [128 128]);
imjpg = imresize( imread('lena.jpg'), [128 128]));
imbmp = imresize( imread('lena.bmp'), [128 128]));
and that then after that if you pass the results through the two different encryption methods, that they take different amounts of time, that can repeatably vary up to a full minute in timings?
Have you tried executing them in a random order to determine whether you might be getting some kind of order effect (sometimes the first time running code can be much slower)?

Sign in to comment.

Image Analyst
Image Analyst on 7 May 2016
I think you probably meant to use the word encoding and decoding rather than encrypting and decrypting. Saving a file encoded as PNG is an entirely different thing than taking an image array and encrypting it. Encoding uses a well described protocol and does not need any password or passkey or anything like that. So if you encode according to the BMP format for example, anyone can decode it because it is not encrypted.
Yes there will be slight differences because they use different formats, and some take time to compress the data while others don't. However the ones that compress take less time to save to disk that may or may not save more time than the excess time spent compressing. You just have to try it and see for different sized images. Do it over a big size range, like ten to one or so.


Find more on Encryption / Cryptography in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!