我正在做一个项目,我需要使用LSB水印技术将半色调置换图像嵌入基础原始图像。我在浏览互联网时发现了以下代码,但在执行时会抛出以下错误。
??? Error using ==> bin2dec
Binary string may consist only of characters 0 and 1
Error in ==> hi77 at 71
final = bin2dec(baseImage);
代码:
wm_image = reshape(outImg(randperm(numel(outImg))),size(outImg)); % permuted watermark image.
figure;
imshow(wm_image);
[wm_row,wm_col]=size(wm_image);
wm = dec2bin(wm_image);
wmlength = wm_row*wm_col;
baseImagelength = row*col;
baseImage = dec2bin(inImg);% Original gray scale image
i=1;
j=1;
k=1;
counter=0;
while i < baseImagelength
counter=counter+1;
if counter > wmlength
break;
end
baseImage(i,8)=wm(j,k);
k=k+1;
if k>8
k=1;
j=j+1;
end
i=i+1;
end
key1=wm_row
key2=wm_col
final = bin2dec(baseImage);
final = reshape(final,row,col);
img1(1:row,1:col)=final(1:row,1:col);
imshow(img1);
请使用上述代码帮助任何人。