need help
Hi,
This is Archana, an engineering student. I am working on a project in steganography using matlab. For the purpose of hiding the message in the bmp image. I am using the Least Significant Bit (LSB) technique. The problem I am facing is that for the message to be hidden I need to convert the pixel values of the cover image into binary values. I have a code obtained in one of the matlab websites which works fine when i just convert some text data into binary. But when i try to convert the pixel values into binary the program goes into an indefinite loop and never comes out of it. I am not able to debug this error. I am pasting the code below. I need a solution for this error.
function [bindat, binmat] = readdata(filename);
% Funfunction [bindat, binmat] = readdata(filename);
% Purpose: Read in the data
% filename must be a string
% binmat is the resulting matrix of binary. binstream is used for user's
% verification of bindat
% bindat is the resulting stream of binary data
% Initialize bindata
bindata = [];
% Open the file
fid = fopen(filename,'rb');
% Scan the contents of the file. Scan in the contents as characters.
charstream = fscanf(fid, '%c');
% Convert the stream to uint8
intstream = uint8(charstream);
% Convert uint8 to binary
binmat = dec2bin(intstream);
% Convert binary matrix to binary stream
[row,col] = size(binmat);
for i=1:row
for j=1:col
bindata = [bindata binmat(row*(j-1) + i)];
end
end
bindat= bindata;
% Close the file
fclose(fid);
This does not belong in the AI forum. I'm moving it to the General Programming forum, since it is general programming related (Matlab coding in this case).
Cheers,
Timkin
Cheers,
Timkin
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement