MATLAB: Error in Image Embedding….

binary imageembeddedembeddinggray scaleguiimage processingwatermark

Hello i am trying to run following code…
i=imread('lena.tif');
s=double(i);
j=imread('watermark.bmp');
w=double(j);
[m,n]=size(s);
[g,h]=size(w);
x=dec2bin(s,8); % decimal to binary transformation
y=double(x);
y=y-48;
plane=cell(1,8);
for r=1:8
plane{r}=y(:,r);
end
for r=1:8
planes{r}=reshape(plane{r},m,n);
end
but i am getting error as follows: ??? Operands to the and && operators must be convertible to logical scalar values.
Error in ==> dec2bin at 31 if any(d < 0) any(~isfinite(d))
Error in ==> Un2 at 13 x=dec2bin(s,8); % decimal to binary transformation
my image size is 512*512 ans watermark size is 64*64.. any one would like to suggest me how can i debug it…thnax and regards….

Best Answer

dec2bin() is not documented as accepting anything other than a scalar.
In practice, dec2bin() accepts a vector, but it does not accept an array of 2 or more dimensions. Thus:
dec2bin(s(:),8)
Related Question