Whats wrong in this why I am getting this error while running the code "retrievedBits = bitget(I(1​:numPixels​NeededForS​tring), bitToSet);"??

1 次查看(过去 30 天)
My code is this
  3 个评论
Geoff Hayes
Geoff Hayes 2018-3-9
One problem is that it doesn't appear that bitToSet is defined...does your error message indicate that this variable is undefined?
Stephen23
Stephen23 2018-3-10
编辑:Stephen23 2018-3-10
Sahana Konchada's "Answer" moved here:
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.

请先登录,再进行评论。

回答(1 个)

Geoff Hayes
Geoff Hayes 2018-3-10
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).

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by