how to find mean gray level value

5 ビュー (過去 30 日間)
Muhammad Harith Ramli
Muhammad Harith Ramli 2016 年 10 月 12 日
function pushbutton1_Callback(hObject, eventdata, handles)
global X;
[filename, pathname] = uigetfile({'*.bmp','All Image Files';...
'*.*','All Files' },'title',...
'D:\MRI\DOI');
X = imread([pathname,filename]);
axes(handles.axes1);
imshow(X);
minGL = min(X(:));
maxGL = max(X(:));
meanGL = mean(X(:));
message = sprintf('The min gray level = %d.\nThe max gray level = %d.\nThe mean gray level = %d.', minGL, maxGL,meanGL);
uiwait(helpdlg(message));
I try to find a mean gray level value in GUI. When i run the code it will give this answer:
What wrong with the code?

採用された回答

Walter Roberson
Walter Roberson 2016 年 10 月 12 日
You are trying to use an sprintf() %d format to print a non-integer value. When you do that, sprintf() uses %e format instead. If you want to print out in floating point, code a %e or %f or %g format.
Remember that the mean of integral values need not be integral itself. For example the mean of 1 and 2 is not going to be an integer.
  1 件のコメント
Muhammad Harith Ramli
Muhammad Harith Ramli 2016 年 10 月 12 日
Thanks

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by