Extract and then insert back a sub-block of a picture using matlab

590 Views Asked by At

I have a picture as an input to matlab $(256\times256)$:

img=imread('cameraman.tif');

I want to embed a watermark using a spatial domain method. For this purpose i choose a random sub-block of the image and make my calculations:

 %random selection of sub-block
 r = randi(256-7);
 c = randi(256-7);
 subblock = img(r:r+7, c:c+7);

After i embed the watermark into the subblock i want to replace the old sub-block of the image with the new generated sub-block that contains also the watermark. How can i insert the new sub-block values inside the original picture?

1

There are 1 best solutions below

0
On BEST ANSWER
img(r:r+7, c:c+7) = modified_subblock;