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

@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.
I had done the changes.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2018년 3월 9일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Function Creation에 대해 자세히 알아보기

질문:

2018년 3월 8일

답변:

2018년 3월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by