Image watermarking using LSB

3 次查看(过去 30 天)
Below are few line from LSB image watermarking. Please can someone explain why we divide by 32 in the first code line. Why do we choose 224 and 248 for image2hide and coverImage and not same number or other number
im2hide = bitand(floor(im2hide), 224) / 32;
coverimage = bitand(floor(coverimage), 248);
same way why 7 * 32 is done in decryption line
im2hide = bitand(floor(watermarkedIm), 7) * 32;
  1 个评论
Christoph F.
Christoph F. 2018-3-8
It looks like the code is doing some bit manipulation on the raw pixel data. What image format is used for im2hide?

请先登录,再进行评论。

采纳的回答

Guillaume
Guillaume 2018-3-8
编辑:Guillaume 2018-3-8
This is simple bit masking and shifting. Whenever you encounter this sort of thing, if you're not familiar with powers of 2, then convert the decimal values to binary to see which bits are actually kept or discarded.
anding with 224 (11100000b) keep the 3 highest bits. Dividing by 32 then shift these bits to the 3 lowest, hence that first line is equivalent to:
im2hide = bitshit(floor(im2hide), -5)
The second line is another masking operation, this time with 11111000b, hence it keeps the 5 highest bit.
The third line is the reverse of the first, it keeps the lowest 3 bits. Then multipliying by 32 shifts these 3 bits to the highest 3 bits, and it is thus equivalent to:
im2hide = bitshift(floor(watermarkedIm), 5);
I'm not sure why the floor are there. If you're dealing with integers (as you should since we're talking about integer bits), they serve no purpose.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by