这个隐写术提取代码有什么问题?

-4 matlab steganography extract

我想尝试从之前插入消息的图像中提取消息..但是下面的描述有错误.

这段代码提取:

% Read Image Stego
IS = imread('imagestego.bmp');

% Extract RedChannel
RedChannel = IS(:,:,1);

% Convert RedChannel to biner
bitstego = uint8(reshape(dec2bin(RedChannel,8)',1,[]) = '0');
nBitstego = length(bitstego);

% Extraction
extBits = bitget(RedChannel(1:end),1).';
extMessage = char(bin2dec(reshape(int2str(extBits),8,[]).').');
Run Code Online (Sandbox Code Playgroud)

和提取代码中的此错误:

>> latihanextract
Error: File: latihanextract.m Line: 8 Column: 55
The expression to the left of the equals sign is not a valid target for an assignment.
Run Code Online (Sandbox Code Playgroud)

这是嵌入代码之前......的工作!

coverImage = imread('foto1.jpg');
message = 'IMRON';

%EMBEDDING
RedChannel = coverImage(:,:,1);
GreenChannel = coverImage(:,:,2);
BlueChannel = coverImage(:,:,3);
bits = uint8(reshape(dec2bin(message,8)',1,[]) - '0');
nBits = length(bits);
RedChannel(1:nBits) = bitset(RedChannel(1:nBits),1,bits);
Imageresults = cat(3,RedChannel,GreenChannel,BlueChannel);
imwrite(Imageresults,'imagestego.bmp');
Run Code Online (Sandbox Code Playgroud)

所以有什么问题 ?

bea*_*ker 6

这是你的问题......

% Read Image Stego
IS = imread('stegosaurus.bmp');

% Extract RedChannel
RedChannel = IS(:,:,1);

% Convert RedChannel to binary
bitstego = uint8(reshape(dec2bin(RedChannel,8)',1,[]) - '0');
nBitstego = length(bitstego);
% the previous 2 lines are actually unnecessary and can be deleted...
% see explanation in text below

% Extrication
extBits = bitget(RedChannel(1:end),1).';   % (1:end) gives you all of the elements
extMessage = char(bin2dec(reshape(int2str(extBits),8,[]).').')
Run Code Online (Sandbox Code Playgroud)

您试图循环图像中的位数而不是字节数.bitstego是所有字节的二进制表示bitstego,因此bitstego是8倍RedChannel.

在这种情况下,仅RedChannel使用特殊索引中的元素数量就容易得多end.