How do I solve this particular error? First-time MATLAB user
Show older comments
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
on 12 Apr 2014
0 votes
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.
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
Blake
on 13 Apr 2014
Alberto
on 13 Apr 2014
The proper syntax is:
tm=mean2(wr);
Image Analyst
on 13 Apr 2014
Put your cursor in meanTwo and type control D. What does it say? It will probably say that there is no meanTwo on the search path and ask you if you want to write a new function called meanTwo.
Your original code showed mean2(), which is in the Image Processing Toolbox. So evidently you changed it for some reason to meanTwo(). Why? If you don't have the IPTB, you can use mean(wr(:)) instead of mean2(twr).
Blake
on 13 Apr 2014
Image Analyst
on 13 Apr 2014
Not sure what you tried, but did you try this:
ts=std(wr(:));
Blake
on 13 Apr 2014
Image Analyst
on 13 Apr 2014
Type "ver" to see what toolboxes you have. Is the Image Processing Toolbox listed?
Blake
on 15 Apr 2014
Blake
on 18 Apr 2014
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
on 21 Apr 2014
Categories
Find more on Image Arithmetic 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!