How to jump to next sub-block in image
Show older comments
Hi all. I want ask how to embed and retrieve data from block to block? Because I can get the data at the entire block only. Thanks for your help.
5 Comments
Walter Roberson
on 26 Jan 2013
Are you asking how to break an image up into sub-blocks ?
Willam Willam
on 26 Jan 2013
Willam Willam
on 26 Jan 2013
Willam Willam
on 26 Jan 2013
Accepted Answer
More Answers (2)
extract= yourimage(i+(0:M-1),j+(0:N-1))
or
yourimage(i+(0:M-1),j+(0:N-1)) = embed
1 Comment
Willam Willam
on 26 Jan 2013
Matt J
on 27 Jan 2013
I only vaguely understand what you're doing, but nowhere in your code do you show where "block" originally comes from or how you update it. Maybe the problem is that you are not updating it.
Below might be something like what you're looking for for the 'embed' part. The 'extract' would probably be very similar. I'm using MAT2TILES which is available here
C=mat2tiles(YourImage,[2,2]);
W=C;
for i=1:numel(C);
block=C{i};
n=1;
for r=1:2
for c=1:2
block(r,c)=bitset(block(r,c),1,embed(n));
n=n+1;
block(r,c)=bitset(block(r,c),2,embed(n));
n=n+1;
end
end
W{i}=block;
end
watermarked_image=cell2mat(W);
5 Comments
Willam Willam
on 1 Feb 2013
Matt J
on 1 Feb 2013
Here's a small example to convey the general idea. I start with a 4x4 image A, which I will think of as composed of 2x2 blocks (four of them)
>> A=reshape((1:16).',4,4)
A =
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
Now, I use mat2tiles to assign the 2x2 blocks to cells.
>> C=mat2tiles(A,[2,2])
C =
[2x2 double] [2x2 double]
[2x2 double] [2x2 double]
Now I will do something simple like loop through and display all 4 blocks. The point is that I can index each block individually as C{i}
>> for ii=1:4, C{ii}, end
ans =
1 5
2 6
ans =
3 7
4 8
ans =
9 13
10 14
ans =
11 15
12 16
Willam Willam
on 1 Feb 2013
Matt J
on 1 Feb 2013
Yes. I showed you a few comments ago how your 'embed' code would change.
Willam Willam
on 1 Feb 2013
Categories
Find more on Signal Attributes and Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!