Encryption 如何在图像中封装一些文本信息并使用MATLAB提取?

Encryption 如何在图像中封装一些文本信息并使用MATLAB提取?,encryption,matlab,steganography,Encryption,Matlab,Steganography,有人能用MATALB的内置图像来说明吗?我相信您正在寻找。您可以从的这个MATLAB实现开始 LSB隐写术的一种简单方法是获取无损压缩图像并设置每个分量(R、G、B)的LSB。然后,对于一个mxn图像,你可以得到3mn位来存储信息。由于您正在修改LSB,因此在图像中看不到差异 更新 因此,我决定编写一个小型、低效但具有示范性的示例: new_img = convert(img, text); (img, text) = convert_back(new_img); 我下载了这个工具,它工作起来

有人能用MATALB的内置图像来说明吗?

我相信您正在寻找。您可以从的这个MATLAB实现开始

LSB隐写术的一种简单方法是获取无损压缩图像并设置每个分量(R、G、B)的LSB。然后,对于一个mxn图像,你可以得到3mn位来存储信息。由于您正在修改LSB,因此在图像中看不到差异

更新

因此,我决定编写一个小型、低效但具有示范性的示例:

new_img = convert(img, text);
(img, text) = convert_back(new_img);

我下载了这个工具,它工作起来很有魅力,但是有
.p
.fig
文件,它们是如何工作的?@user198729:决定编写一个小例子。试试看;)哦,真管用!但我不明白…你能在那里多加评论吗?像
b=dec2bin(文本,8);%
b=b(:)?哈哈,当然。这是LSB隐写术,但我相信有更好的方法,所以祝你好运!对不起,我还是不知道如何
;%可以工作,我以前从未使用过这种语法,不过通过测试,我发现它将
8
位与
16
位数组相结合。
function LSBStega    
        %%// Image and text
        I = imread('coins.png');
        text = 'Hello World etc';
        assert(numel(I) > numel(text)*8,'Insufficient number of pixels');

        %%// Encode
        %// The end character signifies the end of the hidden text
        end_char = '.';
        %// Append it
        text = [text end_char];
        %// Convert each character into binary form with atleast 8 bits
        %// We transpose it before calling (:) since the binary representation
        %// is stores each character in binary per row and the (:) operations
        %// vectorizes the matrix by column.
        b = transpose(dec2bin(text,8));
        %// Find which bits should be set to 1 or 0
        ind_0 = find(b == '0');
        ind_1 = find(b == '1');
        %// Set the appropriate bits to 1 and 0 and leave the rest alone
        I(ind_0) = bitset(I(ind_0),1,0);
        I(ind_1) = bitset(I(ind_1),1,1);

        %%// Faster decode
        text_back = [];        
        for i = 1:8:numel(I)
            %// Extract the LSB from a set of 8 bytes in the image
            C = bitget(I(i:i+7),1);
            %// Convert from binary to decimal
            C = bin2dec(num2str(C));
            %// Check if it's the end character; break if so, store if not
            if(C == end_char) 
                break;
            else
                text_back(end+1) = C;
            end
        end
        %// Convert to text
        text_back = char(text_back);

        %%// Display
        subplot(1,2,1);
        title('Original');
        imshow(imread('coins.png'));
        subplot(1,2,2);
        title('Steganography Result');
        imshow(I);
        disp(text_back);    
end