How to save image after encryption?
2 views (last 30 days)
I have code for encrypt an image, then ineed to save image after encryption to use it in another seperate code .
which command is prefere, imsave, imwrite? I try to use both but the saved image can't be showed correctly when i used imshow command.
Walter Roberson on 16 Jan 2022
My suspicion would be that your original image is uint8 and that when you did the encryption, you did not make sure to create uint8 . Perhaps your results are all integers 0 to 255, but I suspect that class() of them is double() .
If your encrypted image is double() but only uses integers 0 to 255, then uint8() it.
If your encrypted image is double() but has some entries that are not integers 0 to 255, then you might have a problem.
Image Analyst on 16 Jan 2022
Unless your encryption produced another uint8 or uint16 image, you're probably best just saving it as a binary file with a .bin or .dat extension since no standard program will be able to read it and decrypt it successfully if you save as a .PNG extension - it will just confuse them and they'll throw an error. Something like (untested):
fid = fopen('encryptedImage.bin', 'wb');
fprintf(fid, '%c', yourImage);