How should I solve the "output argument not assigned" problem(GUI function)?
古いコメントを表示
Hello, everyone. I want to turn a image into binary image, and to determine the threshold gray level according to the resulted binary image. So I design a function, in which a GUI will pop out showing the current threshold value and the binarized image. You can modify the threshold and see the new binarized image imediately. After several modifying, if you think the binarized image is OK, you click the OK button and the function returns the current threshold. All of these GUI functionality is realized by callback functions.
But when I call that function, the error message says:
??? Output argument "threshold_value" (and maybe others) not assigned during call to
the main function is
raw_image = imread('beauty.jpg');
raw_image = rgb2gray(raw_image);
max(raw_image(:));
raw_image = im2double(raw_image);
max(raw_image(:));
threshold_value = get_threshold_value(raw_image)
The function I designed is:
function threshold_value = get_threshold_value(raw_image)
% This function is used to get the wanted threshold value, by saying wanted
% I mean the threshold judged by the user, and the value can binarize the
% image appropriately.
%%initialization
current_value = 0.5;
step_value = 0.05;
% preprocessed_image = rgb2gray(raw_image);
preprocessed_image = im2double(raw_image);
binary_image = [];
......
function ok_button_callback(source, eventdata)
threshold_value = current_value;
close(handle_new_figure)
end
end
2 件のコメント
The Pirate
2017 年 7 月 25 日
per isakson
2017 年 7 月 25 日
編集済み: per isakson
2017 年 7 月 25 日
"??? Output argument "threshold_value" (and maybe others) not assigned " I guess, the nested function isn't called during the execution of get_threshold_value.
Put a breakpoint at the line, threshold_value=current_value;, and run the function, get_threshold_value, to find out.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で 图像类型转换 についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!