Question: First script of code for hidden message.m % Ask the user for the image filenameimageFilename = input ( 'Enter the image filename ( including extension

First script of code for hidden message.m%Ask the user for the image filenameimageFilename = input( 'Enter the image filename (including extension): ,s%file name is flower. jpg%Read the image into MATLAB using imreadImage = imread (imageFilename) ;% Convert image to grayscale if necessary if size (image,3)==3image = rgb2gray (image);End% Search the image for existing values equal to zero and replace them with onesimage (image =0)=1;% Ask the user for the message to embedmessage = input( 'Enter the message to embed: ','s');% Convert message to binarybinaryMessage ='';for i =1: length (message)binaryMessage = strcat (binaryMessage, dec2bin (message(i),8));% Convert binary message to array of charactersbinaryMessageChars = num2cell (binaryMessage) ;% Create a matrix with the same size as the image to hold the binary messagebinaryMatrix = zeros (size (image,1), size(image,2), 'uint8');% Put each letter of the string on a new row in the binary matrixfori=1:numel(binaryMessageChars)binaryMatrix(i,1:8)= uint8(str2double(binaryMessageChars{i}));End% Scan the binary matrix for values of 1 and set the corresonding points inimage to zero (black)Image(binaryMatrix ==1)=0;% Display the updated image imshow (image) ;title( 'Image with Hidden Message');Second script of code for decode message.m%read the image fileimg = imread ( 'flower.jpg');%extract the binary message from the image message =;for i =1: size (img,1)row = img (i,:,:);for j =1:size (img,2)pixel = row(j,:);message = strcat(message, num2str(pixel (1))) ;End End % convert the binary message to ascii charactersdecoded _message =";for i =1:7length (message)if i+6<= length (message)decoded_message =strcat(decoded_message, char (bin2dec(message (i: i+6))));elsebreak;End End These are two different scripts of code, the first one used to hide a message into a picture uploaded and the second script to decode the message hidden in the picture. In my decode message.m script I get a message in my command window in Matlab saying index in position 1 exceeds array bounds, and error in decodeMessage pixel = row(j,:);
Why am I getting this error and fix the code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!