Why i didnt get the image back during decryption using this inverse code ?

I used the below code for image scrambling and unscrambling. But i didnt get the exact image in unscrambling. In the decrypted image the upper portion is at the bottom position, that is the hat in the lena image comes at bottom. Please help me to rectify it.
ite=1;
[rown,coln]=size(im);
for i=1:rown
for j=1:coln
itecount=1;
nrowp=i;
ncolp=j;
while(itecount<=ite)
newcord =[1 1;1 2]*[nrowp ncolp]';
nrowp=newcord(1);
ncolp=newcord(2);
itecount=itecount+1;
end
encim(i,j)=im((mod(nrowp,rown)+1),(mod(ncolp,coln)+1));
end
end
%INVERSE
figure,imshow(im)
impixelinfo
figure,imshow(uint8(encim))
impixelinfo
[rown,coln]=size(encim)
for i=1:rown
for j=1:coln
itecount=1;
nrowp=i;
ncolp=j;
while(itecount<=ite)
newcord =[2 -1;-1 1]*[nrowp-1 ncolp-1]';
nrowp=newcord(1);
ncolp=newcord(2);
itecount=itecount+1;
end
decim(i,j)=encim((mod(nrowp,rown)+1),(mod(ncolp,coln)+1));
end
end
figure,imshow(uint8(decim))
impixelinfo

4 Commenti

@Sneha P S: Do you see, that your code is not readable? Don't you have the impression, that posting readable code is essential, when you want others to help you? I cannot imagine, why so many newcomers simply do not care about this. Didn't you look at other threads at first and see, that they contain properly formatted code?
Please mark your code and press the "{} Code" button. Thank you.
Am really sorry for what i had done. I didnt notice the preview part because it was in format while am editing. Sorry for that and now i corrected it. Could any one please help me.
@Sneha P S: There is no need to be sorry. But let me mention, that your code is still not formatted properly. Now there is a blank line after each line of code, some parts are recognized as code (due to the leading spaces), but some are not. Please read: Tutorial: How to format text in the forum.

Accedi per commentare.

Risposte (1)

I'm not sure what this uncommented code does. Is it the Arnold cat map? Just regular scrambling? I'm attaching demos for both. Since I don't know what your image does (due to lack of comments/explanations), I don't know how to fix it.

Categorie

Richiesto:

il 8 Mar 2018

Risposto:

il 9 Mar 2018

Community Treasure Hunt

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

Start Hunting!

Translated by