Function 'subsindex' is not defined for values of class 'struct'. Error in decoder_test (line 18) binpix= de2bi(stego(key(i)),8);
Show older comments
I have the following dencoder code for a Stegonagraphy assignment. but I keep getting the following error
*Function 'subsindex' is not defined for values of class 'struct'.
Error in decoder_test (line 18)
binpix= de2bi(stego(key(i)),8);*
%decoder program
%load image and key to decode
stego = imread('stegoimmage.tif');
key = load('key.mat');
%decode the image by retrieving the LSB
for i=1:8
%
binpix= de2bi(stego(key(i)),8);
% going to change the 1st significant bit with the 1st bit of our message
binpix(1)=binmessage(i);
%puts the new value back into the original location of were the number was
%removed. converts it to decimal first before it puts it back
stego(key(i))=bi2de(binpix);
end
%conversions
ascmessage = bi2de(binmessage);
message = uint8(ascmessage);
%display the hidden message
I need to be able to retrieve the hidden message from the picture. but cant get past this message. please help
Answers (2)
Steven Lord
on 29 Feb 2016
0 votes
The variable key is a struct array. MATLAB doesn't know how to use a struct array as an index; you need to extract the data from one of the fields of key and use that data to index into stego.
1 Comment
Sergio Gomez
on 29 Feb 2016
Guillaume
on 29 Feb 2016
key = load('key.mat')
This will create a structure key with fields named after each variable in the 'key.mat' file. Without seeing the mat file, it's impossible for us to tell you the names of the fields of that structure. And even then, we would need to know which variable in the mat file you want to use as index
Possibly, if your mat file contains the variable key that you want to use as index, this would work:
matcontent = load('key.mat');
key = matcontent.key;
2 Comments
Sergio Gomez
on 29 Feb 2016
Guillaume
on 29 Feb 2016
transpose the array:
message = message'
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!