フィルターのクリア

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).
  2 件のコメント
Sahana Konchada
Sahana Konchada 2018 年 3 月 12 日
So what I have to do to replace the error in my code? Where I have to modify the code?
Walter Roberson
Walter Roberson 2018 年 3 月 12 日
At the top of your code assign 8 to bitToSet

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by