How do I solve this particular error? First-time MATLAB user

1 view (last 30 days)
This is the code I'm trying to run:
%Blind embedding and linear correlation detection
clear all;
%Generate a reference pattern the same size as the images
wr=randn(112,92);
tm=mean2(wr);
wr=wr-tm;%zero mean
ts=std2(wr);
wr=wr/ts;%unit variance
%Show the reference pattern
figure
imshow(wr,[]);
%400 face images, 112 x 92 pixels, in 40 folders of 10 images each
numclass=40;
numface=10;
for s=1:numclass
for i=1:numface
%Read image
c0=double(imread(strcat('C:\facedb_bmp\s',num2str(s),'\', num2str(i),'.bmp')));
%Add reference pattern to the image to embed a 1
wa=double(c0+wr);
%Add negative reference pattern to the image to embed a 0
nwr=wr*-1;
nwa=double(c0+nwr);
%Calculate linear correlation for images carrying a 1, a 0,
%or no watermark and store it into a vector
corr1(10*(s-1)+i)=sum(sum(wa.*wr))/(112*92);
corr0(10*(s-1)+i)=sum(sum(nwa.*wr))/(112*92);
corrN(10*(s-1)+i)=sum(sum(c0.*wr))/(112*92);
end
end
%Calculate the histograms for the detection-value vectors
[a1,b1]=hist(corr1,-3:0.1:3);
[a2,b2]=hist(corr0,-3:0.1:3);
[a3,b3]=hist(corrN,-3:0.1:3);
%Plot the histograms
figure
plot(b2,a2/400*100,'red');
gtext('m=0');
hold;
plot(b3,a3/400*100,'green');
gtext('No watermark');
plot(b1,a1/400*100,'blue');
gtext('m=1');
xlabel('Detection value');
ylabel('Percentage of images');
if true
% code
end
When I click 'Save and Run', it gives me this error:
??? Undefined function or method 'blind' for input arguments of type 'char'.
Can anyone help me out? Also the image I'm using is Lena.tiff. I know I need to change the directory from C: onwards but do I also need to change .bmp to .tiff? Any help would be much appreciated.

Answers (2)

Alberto
Alberto on 12 Apr 2014
Looks like you are using a function 'blind': there is not such command, and probably doesnt have a made up function.
The point is you are calling an undefined function.
  4 Comments
Blake
Blake on 12 Apr 2014
I believe you are mistaken, I've shown you the entirety of my code.
Alberto
Alberto on 12 Apr 2014
That's what the error message suggest.
I tried to run the code and doesn't appear any error message. Maybe the error is not the code.

Sign in to comment.


Walter Roberson
Walter Roberson on 13 Apr 2014
Look at your first few characters:
%Blind
If for some reason the '%' is not being recognized as a comment character then that line would be interpreted as a call to "Blind" with the rest of the line as character arguments.
What, by the way, did you name your source file? The source file name must start with a letter, and be followed by letters, digits, or underscore (no spaces) to a maximum of 63 characters, after which there should be a '.m' extension.
  11 Comments
Image Analyst
Image Analyst on 18 Apr 2014
Here's an idea http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/ After that, you will discover how to find the sizes of c0 and wr, and learn that they are different sizes. You can only add matrices if they are the same size, don't you agree? How could you add a 2 by 3 matrix to a 1024 by 960 matrix?
Blake
Blake on 21 Apr 2014
Thank you very much I learnt a lot from that video and finally ran the code successfully

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!