How to define hx(i,j) in matlab ?

6 views (last 30 days)
marie lasz
marie lasz on 21 Dec 2020
Commented: marie lasz on 23 Dec 2020
Hey all,
I want to use the formula i.e, hx(i,j)=kx(i,j)*1; instead of kx(i,j)=kx(i,j)+-25;
how can I define hx(i,j) here and how i should proceed with hx value in last lines of code? I guess hx(i,j) should be a empty matrix if I am not wrong?
Any help would be appreciated.
Thanks
i=[]; j=[]; w=1; wmrk=Watermark_Image; welem=numel(wmrk); % welem - no. of elements
prompt = {'Enter embedding location 1 (1-8)','Enter embedding location 2 (1-8)'};
dlg_title = 'Input for watermark embedding location';
num_lines = 1;
def = {'8','8'};
val_i_j = inputdlg(prompt,dlg_title,num_lines,def);
em=zeros(8);
for k=1:4096
kx=(x{k});
for i=1:8 % To address the rows of the blocks
for j=1:8 % To address the column of the blocks
if (i==str2num(val_i_j{1})) && (j==str2num(val_i_j{2})) && (w<=welem) % Criteria to insert watermark
% location in the 8*8 block
if wmrk(w)==0
kx(i,j)=kx(i,j)+25;
end
elseif wmrk(w)==1
kx(i,j)=kx(i,j)-25;
end
end
end
w=w+1;
x{k}=em(i,j); kx=[]; % Watermark value will be replaced in the block
end

Answers (1)

Image Analyst
Image Analyst on 22 Dec 2020
So go ahead and do it
kx(i,j)=kx(i,j)+-25; % Still need kx because you're going to set hx equal to it.
hx(i,j)=kx(i,j)*1; % instead of kx(i,j)=kx(i,j)+-25;
I have no idea what k or h is, or how you want to treat them differently after the loops end.
  3 Comments
Image Analyst
Image Analyst on 22 Dec 2020
To recombine maybe you should use montage() or imtile()
marie lasz
marie lasz on 23 Dec 2020
thanks , you were very close to the real problem . Because I think the problem is with the inverse of dct because I am getting so much manipulated image. I am trying to figure out this problem.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!