MATLAB: I need this code working. I am not able to figure out the problem.

image encryptionlorenz equations

Hello Everyone This code is an chaotic Image Encryption Code. I am Not able to Run this code Because it is giving errors. I am attaching a rar Matlab file. Pls can someone correct it for me.. Thanks in advance

Best Answer

Yagyesh - running the code produces the following error message
Index exceeds matrix dimensions.
Error in encryptImage (line 36)
B=I(:,:,2);
encryptImage is what I named the function to do the encryption. Putting a breakpoint at the first line, and running the function, stops at line
I = imread('lena.bmp');
Step past this line and the problem is clear. I is a two-dimensional 256x256 matrix of 8-bit unsigned integers. The lena.bmp is a black and white image, with no red, green or blue channels. Once the code reaches
A=I(:,:,1);
B=I(:,:,2);
C=I(:,:,3);
A is assigned correctly since I is 256x256 (or 256x256x1), but the two lines fail after that.
It would appear that the code has been written with the expectation of handling images with three dimensions.
I suggest that you try with a different image (one that has three dimensions), or adjust the code to handle the case where ndims(I)==2 (and so avoid all B and C "channel" work).