Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
When i type an input of the word hi into the encoder code, and then go throught the decoding, the decoder gives an output of <A, will someomne please help me. i have debugged it several times and cant seem to find a problem.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
% This program will hide a messege in a picture and
% then decode it to show the messege.
% Michael McClung
% 10/14/2016
clc;
clear;
%***********Endcoder******************************************************%
% Asking user to give the name of the file wanted to store the messege in
pictureAskedFor = input('Please enter the name of the image for the cover image: \n', 's');
% Asking user to type a messege to hide in a picture
usersMessegeInLetter = input('\nPlease type a messege to hide in your picture: ', 's');
% Converting users messege from ascii to decimal
letterToDecimal=uint8(usersMessegeInLetter);
% UsersCoverPic variable name for pictureAskedFor for later use
usersCoverPic = rgb2gray(imread(pictureAskedFor));
% Size of cover picture placed into rows and comlumns
[rows, columns] = size(usersCoverPic);
% Converting users binaryMessege from decimal to binary
binaryMessege=dec2bin(letterToDecimal,8);
% Picture to hide bits in
stegoImage=usersCoverPic;
% The length of the messege of how many bits
lengthOfMessege=length(usersMessegeInLetter);
% Rows and Column of the array & length of messege in binary
key=randperm(rows*columns,lengthOfMessege*8);
% Hides binary LSBs into pixels of the image
for i=1:lengthOfMessege*8
binaryInPixels=dec2bin(usersCoverPic(key(i)),8);
binaryInPixels(1)=binaryMessege(i);
stegoImage(key(i))=bin2dec(binaryInPixels);
end
% Saving for the key by stating its variable name
save('keyOfEncoder.mat','key');
% Saving of the stego image
imwrite(stegoImage,'stegoImage.tiff');
figure
subplot(1,2,1);
% Shows stego image to compare to original image asked for
imshow(stegoImage);
title('Stego Image');
subplot(1,2,2);
% Shows stego image to compare to original image asked for
imshow(pictureAskedFor);
title('Oringal Image');
fprintf('\nFile name, lion.jpg, has been saved as stegoImage.tiff and keyOfEncoder.mat\n\n');
%***************End Of Encoder********************************************%
%***********Decoder*******************************************************%
% Asking user to give the name of the file to reveal the messege
tiffFileAskedFor = input('Please enter the name of the .tiff image to \n reveal the messesge by decoding: \n', 's');
% Asking user to type a messege to hide in a picture
keyOfEncoder = input('\nPlease type the name of the .mat file to \n help the decoding process: ', 's');
% Load the key for the decoder
load(keyOfEncoder);
% DecodableTiffImage variable name for tiffFileAskedFor for later use
decodableTiffImage = imread(tiffFileAskedFor);
% The length of the messege of how many bits
lengthOfMessege=length(keyOfEncoder);
% Hides binary LSBs into pixels of the image
for i=1:lengthOfMessege
imagePoints=dec2bin(decodableTiffImage(key(i)),8);
arrayPoints(i)=imagePoints(1);
end
% Output messege stating what the messege says
fprintf(' Your messege says: ');
% Calculations of decoding the pixels of the image to output the messege
for letterOfMessege=1:lengthOfMessege/8
for i=1:8
alphabet(i)=arrayPoints(((letterOfMessege-1)*8)+i);
end
disp(char(bin2dec(alphabet(i))));
end
0 Commenti
Risposte (0)
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!