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.mAsk the user for the image filenameimageFilename input 'Enter the image filename including extension: sfile name is flower. jpgRead the image into MATLAB using imreadImage imread imageFilename ; Convert image to grayscale if necessary if size imageimage rgbgray image;End Search the image for existing values equal to zero and replace them with onesimage image ; Ask the user for the message to embedmessage input 'Enter the message to embed: s; Convert message to binarybinaryMessage ;for i : length messagebinaryMessage strcat binaryMessage decbin messagei; Convert binary message to array of charactersbinaryMessageChars numcell binaryMessage ; Create a matrix with the same size as the image to hold the binary messagebinaryMatrix zeros size image sizeimage 'uint; Put each letter of the string on a new row in the binary matrixfori:numelbinaryMessageCharsbinaryMatrixi: uintstrdoublebinaryMessageCharsi;End Scan the binary matrix for values of and set the corresonding points inimage to zero blackImagebinaryMatrix ; Display the updated image imshow image ;title 'Image with Hidden Message';Second script of code for decode message.mread the image fileimg imread 'flower.jpg;extract the binary message from the image message ;for i : size imgrow img i::;for j :size imgpixel rowj:;message strcatmessage numstrpixel ;End End convert the binary message to ascii charactersdecoded message ;for i :length messageif i length messagedecodedmessage strcatdecodedmessage, char bindecmessage i: i;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 exceeds array bounds, and error in decodeMessage pixel rowj:;
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
