0

我有一个问题想在这里提出。我的问题是我想将每个字符的 2 LSB 嵌入到 2 * 2 矩阵中并连续嵌入,直到数据全部成功嵌入。但现在我做不到了。非常感谢您的帮助。这是我的部分代码。

fid = fopen('test.txt'); %open the text file
readText = fread(fid);
fclose(fid); %close the file function
char_in_bit = uint8(readText);
ascii_binary = dec2bin(char_in_bit,7);
size_char = size(char_in_bit); %determine the length of the text file
display(char_in_bit);
display(size_char);

display(BlockRONI);
display(ascii_binary);

for a=1 : size(ascii_binary,1)
    for b=1:6
        if blocksize==2
        n=1;
        for r=1:2
            for c=1:2
                block(r,c)=bitset(block(r,c),1,char_in_bit(n));
                n=n+1;
                block(r,c)=bitset(block(r,c),2,char_in_bit(n));
                %display(block(r,c));
            end
        end
        end
    end
    block(r,c) = bitset(block(r,c), 7, char_in_bit(n));
end

watermarked_image(y2:y2+blocksize-1, x2:x2+blocksize-1)=block;
watermarked_image_int=uint8(watermarked_image);
imwrite(watermarked_image_int,'watermarked.jpg');
4

0 回答 0