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

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)

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

thank you for your response. Kx(i,j) includes the 4096 blocks of a matrix i.e 64x64. i j are rows and columns of each block. so in general kx(i,j) defines the dct coefficient. In each host image's coefficient I want it to multiply with + or -1 to change its sign. hx(i,j) is nothing but it should take all the resultant values of this equation. After this I am recombining cells and then applying inverse of dct.
% Recombining cells into an image %
i=[]; j=[]; data=[]; count=0;
New_Image={}; % it will contain the new data of rows cells of 4096 into 64 rows cells
for j=1:64:4096
count=count+1;
for i=j:(j+63)
data=[data,x{i}];
end
New_Image{count}=data;
data=[];
end
% Convertion of 64 row cells into columns to get an image
i=[]; j=[]; data=[];
Output_Image=[]; % watermarked image
for i=1:64
Output_Image=[Output_Image;New_Image{i}];
end
Output_Image=(uint8(blkproc(Output_Image,[8 8],@idct2)));
end
To recombine maybe you should use montage() or imtile()
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.

Asked:

on 21 Dec 2020

Commented:

on 23 Dec 2020

Community Treasure Hunt

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

Start Hunting!