error in decryption code saying not enough input arguments

2 views (last 30 days)
the code is for decrypting a text from an encrypted image .
clc;
close all;
clear all;
img=imread('enc2.gif');
imshow('enc2.gif');
img1=imread('C:\Users\Anushree Bhatt\Desktop\cd1\Major\desert1.jpg');
img1=img1(:,:,3);
[p,q,r]=size(img);
for i=1:q
disp(img(1,1));
disp(img1(1,1));
disp(img(1,i)-img1(1,i));
if (img(1,i)-img1(1,i)==0)
break;
end
text(i)=(img(1,i)-img1(1,i)+96);
end
len=size(text);
k=len(1,2);
text1=zeros(1,k);
for i=1:k
m=text(i)
for j=1:7
if (j-1)>0
a(j-1)=rem(m,2);
else
a(7)=rem(m,2);
end
m=floor(m/2);
disp(m);
if m==1
a(m)=1;
break;
end
end
for j=0:6
text1(i)=text1(i)+a(j+1)*(2^j);
end
end
text1=char(text1);
disp (text1);
X=('The encrypted text is');
disp(X);
disp(text1);
the error is at m=text(i) saying not enough input arguments.i shall post the code for encryption if required.

Accepted Answer

Walter Roberson
Walter Roberson on 6 May 2015
Do not name a variable "text" as that conflicts with the MATLAB graphic function text()
Your code looks through row 1 of the two images, looking for the first column at which the two have the same value. If it happens that the very first location is the same, then your code will never execute the assignment you have currently coded as
text(i)=(img(1,i)-img1(1,i)+96);
and since you do not initialize that variable, the variable would not exist when you go to use it inside the next "for" loop.
You also need to take into account that your imread() is likely returning uint8 values, and that if you subtract a larger uint8 value from a smaller then the result you get is 0, not negative.
disp(uint8(3) - uint8(7)); %is going to give you 0
disp(uint8(7) - uint8(3)); %is going to give you 4
disp(uint8(3) - uint8(7) + 1); %is going to give you 1, because the subtraction gives 0 and you add 1 to that
disp(double(uint8(3)) - double(uint8(7))); %is going to give you -4
  9 Comments
Anushree Bhatt
Anushree Bhatt on 6 May 2015
Edited: Anushree Bhatt on 6 May 2015
Yes , that is not the problem , the problem seems to be at rotating the binary number of ascii code by one digit

Sign in to comment.

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!