In an assignment A(:) = B, the number of elements in A and B must be the same.

1 回表示 (過去 30 日間)
Faradisa
Faradisa 2018 年 2 月 5 日
コメント済み: Torsten 2018 年 2 月 5 日
Hi, I am trying to embed grayscale image to color image (DCT watermarking). I get the error message :
In an assignment A(:) = B, the number of elements in A and B must be the same.
Error in watermark>pushbutton3_Callback (line 167)
zz_dct_koeff(L+1:L+n) = V;
this is the code
alpha = 0.2;
L = 1000;
n = 1000;
a=getappdata(0,'host');
b=getappdata(0,'watermark');
yCbCr = rgb2ycbcr(a);
Y = double(yCbCr(:,:,1));
[xm,xn] = size(Y);
scan_order = jpeg_scan(xm,xn); %access jpeg_scan function
%grayscale image as watermark
wt = double(b);
[M,N] = size(wt);
W = reshape(wt,1,[M*N]);
%transform Y component of host image to DCT
Y_dct = dct2(Y);
temp = Y_dct(:);
zz_dct_koeff = temp;
zz_dct_koeff(scan_order(:)) = temp;
V = zz_dct_koeff(L+1:L+n);
V = V + alpha*abs(V).*W; %perform watermark
zz_dct_koeff(L+1:L+n) = V;
temp = zz_dct_koeff(scan_order(:));
Yx_dct = reshape(temp,xm,xn);
Yx = uint8(idct2(Yx_dct));
yCbCr(:,:,1) = Yx;
wtm = ycbcr2rgb(yCbCr);
axes(handles.axes3);
imshow(wtm);

回答 (1 件)

Torsten
Torsten 2018 年 2 月 5 日
zz_dct_koeff(L+1:L+n) is a single value whereas V is a vector of length M*N.
Thus the assignment
zz_dct_koeff(L+1:L+n) = V;
can't work.
Best wishes
Torsten.
  2 件のコメント
Faradisa
Faradisa 2018 年 2 月 5 日
would you please give the correct one, sir?
Torsten
Torsten 2018 年 2 月 5 日
You are the only person who understands the code you are using. So it's up to you to correct the error I tried to explain to you.
Best wishes
Torsten.

サインインしてコメントする。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by