I am trying to implement LSB watermarking in matlab.But i am getting the error=> Assignment has more non-singleton rhs dimensions than non-singleton subscripts Error in ==> watermarke​d_image(ii​,jj)=bitse​t(watermar​ked_image,​1,watermar​k(ii,jj));

here is the code=>
clc file1='C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg'; [cover_image,map]=imread(file1); %imshow(cover_image,map);
file2='C:\Users\Public\Pictures\Sample Pictures\Hydrangeas.jpg'; [message_image]=imread(file2); %imshow(message_image);
message_image=double(message_image); message_image=round(message_image./256); message_image=uint8(message_image);
O=size(cover_image,1) P=size(cover_image,2)
Q=size(message_image,1) R=size(message_image,2)
for ii = 1:O for jj = 1:P watermark(ii,jj)=message_image(mod(ii,Q)+1,mod(jj,R)+1); end end watermark=double(watermark) watermark=round(watermark./256); watermarked_image=cover_image; for ii =1:O for ii= 1:P watermarked_image(ii,jj)=bitset(watermarked_image,1,watermark(ii,jj)); end end
imshow(watermarked_image)

 Accepted Answer

Chances are you have 3D true color images. So you need to specify a color channel, as in watermark(row, column, colorChannel), not just the row and column, as in watermark(row, column).

6 Comments

Hello sir, according to your solution i tried to modify the code but still getting the same error. so can you tell me whether i have done changes correctly or not.Here is modified code=>
clc
file1='C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg';
[cover_image,map]=imread(file1)
imshow(cover_image,map);
file2='C:\Users\Public\Pictures\Sample Pictures\Hydrangeas.jpg';
[message_image]=imread(file2);
imshow(message_image);
message_image=double(message_image);
message_image=round(message_image./256);
message_image=uint8(message_image);
O=size(cover_image,1)
P=size(cover_image,2)
S=size(cover_image,3)
Q=size(message_image,1)
R=size(message_image,2)
T=size(message_image,3)
for ii = 1:O
for jj = 1:P
for kk=1:S
watermark(ii,jj,kk)=message_image(mod(ii,Q)+1,mod(jj,R)+1,mod(kk,T)+1);
end
end
end
watermark=double(watermark);
watermark=round(watermark./256);
watermarked_image=cover_image;
for ii =1:O
for jj=1:P
for kk=1:S
watermarked_image(ii,jj,kk)=bitset(watermarked_image,1,watermark(ii,jj,kk));
end
end
end
imshow(watermarked_image)
You forgot to attach the images. Use the paper clip icon.
hello sir, I am not able to attach images by using image icon.not understanding how to attach.
Add a comment. Click the paper clip. Click choose file and browse to your image on your hard drive. Click the attach file icon. Click the Save button.
Hello sir,when i tried to attach the images then i got message =>
You are limited to 10 daily uploads. If you need to upload additional files, delete one or more files now or wait 24 hours to upload more files.
Is it means that i have already attached some images?If yes then why i cant see it?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!