Whats wrong in this why I am getting this error while running the code "retrievedBits = bitget(I(1:numPixelsNeededForString), bitToSet);"??
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
My code is this
3 Kommentare
Geoff Hayes
am 9 Mär. 2018
One problem is that it doesn't appear that bitToSet is defined...does your error message indicate that this variable is undefined?
Stephen23
am 10 Mär. 2018
Bearbeitet: Stephen23
am 10 Mär. 2018
Ok I will display the error content.Guide the correct code to remove that error.
Undefined function or variable 'bitsPerLetter'.
Error in Receiverside (line 23) numPixelsNeededForString = 4 * bitsPerLetter;
That what I am getting while running the code. Please check it and tell me what to do to recover from that error.
Antworten (1)
Geoff Hayes
am 10 Mär. 2018
Sahana - it looks like your code is taken from Image Analyst's File Exchange submission at https://www.mathworks.com/matlabcentral/fileexchange/54155-encoding-text-into-image-gray-levels?focused=5790124&tab=function. From that code, you can see how bitsPerLetter is defined as
bitsPerLetter = 7; % For ASCII, this is 7.
and bitToSet is defined from this block of code
%===============================================================================
% Get the bit plane the user wants to use to hide the message in.
% The lowest, least significant bit is numbered 1, and the highest allowable bit plane is 8.
% Values of 5 or more may allow the presence of a hidden text be noticeable in the image in the left column.
% Note: there is really no reason to use any other bit plane than the lowest one, unless you have more text than can fit in the image but then
% you'd have to use multiple bit planes instead of just one. This is a very unlikely situation.
% Ask user for what bitplane they want to use.
defaultValue = 1;
titleBar = 'Enter the bit plane.';
userPrompt = 'Enter the bit plane you want to use (1 through 8)';
caUserInput = inputdlg(userPrompt, titleBar, [1, length(userPrompt) + 15], {num2str(defaultValue)});
if isempty(caUserInput),return,end; % Bail out if they clicked Cancel.
% Round to nearest integer in case they entered a floating point number.
integerValue = round(str2double(cell2mat(caUserInput)));
% Check for a valid integer.
if isnan(integerValue)
% They didn't enter a number.
% They clicked Cancel, or entered a character, symbols, or something else not allowed.
integerValue = defaultValue;
message = sprintf('I said it had to be an integer.\nI will use %d and continue.', integerValue);
uiwait(warndlg(message));
end
bitToSet = integerValue; % Normal value is 1.
if bitToSet < 1
bitToSet = 1;
elseif bitToSet > 8
bitToSet = 8;
end
The error messages are telling you that your code is making use of a variable that has yet to be defined and so you must define these variables as done in the FEX submission where you have taken your code from (or come up with an alternative).
2 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!