Function 'subsindex' is not defined for values of class 'struct'. Error in decoder_test (line 18) binpix= de2bi(stego(key(i)),8);

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)

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

Thanks for the quick response. I understand what you mean, but I cant figure out how to start that. If you could please guide me through the first steps and then I can do the research myself and finish the rest of the way. I have only been using matlab for 3 weeks

Sign in to comment.

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

This really helped me. After some test and trials I have been able to figure it out. My last question is asking on how to change how the message is displayed. Right now it displays it vertically but I need it to display horizontal.

Sign in to comment.

Categories

Asked:

on 29 Feb 2016

Commented:

on 29 Feb 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!