Borrar filtros
Borrar filtros

Image watermarking using LSB

3 visualizaciones (últimos 30 días)
Elysi Cochin
Elysi Cochin el 8 de Mzo. de 2018
Editada: Guillaume el 8 de Mzo. de 2018
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 comentario
Christoph F.
Christoph F. el 8 de Mzo. de 2018
It looks like the code is doing some bit manipulation on the raw pixel data. What image format is used for im2hide?

Iniciar sesión para comentar.

Respuesta aceptada

Guillaume
Guillaume el 8 de Mzo. de 2018
Editada: Guillaume el 8 de Mzo. de 2018
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.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by