How to save image after encryption?

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.

3 Kommentare

Jan
Jan am 16 Jan. 2022
What does "encrypt an image" mean? A file containing in image or the RGB data? What does "can't be showed correctly" mean? Of course an encrypted image does not look "correct".
Arshub
Arshub am 16 Jan. 2022
@Jan i mean : I have an image say 'lena.png ' if i read this image then shuffle the image, we get a new image after shuffle. I need save the new image in a new name say 'lena2.png'.
may be i need the new image 'lena2.png' in anther program to reshuffle the 'lena2.png' to get the original image lena.png '.
Wajid
Wajid am 20 Dez. 2022
imwrite(Lena2,'Lena2.png');

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Walter Roberson
Walter Roberson am 16 Jan. 2022

0 Stimmen

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.

2 Kommentare

Arshub
Arshub am 16 Jan. 2022
yes, may image after permutation in extention double and pixel values between 0 to 255.
but when i save them in png extention, all pixels become 255.
Walter Roberson
Walter Roberson am 16 Jan. 2022
Either be more careful in doing the permutation to retain the original data type, or else take uint8() of the permutation.

Melden Sie sich an, um zu kommentieren.

Image Analyst
Image Analyst am 16 Jan. 2022

0 Stimmen

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);
fclose(fid);

Kategorien

Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2014a

Gefragt:

am 15 Jan. 2022

Kommentiert:

am 20 Dez. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by