How should I solve the "output argument not assigned" problem(GUI function)?
Afficher commentaires plus anciens
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 commentaires
The Pirate
le 25 Juil 2017
per isakson
le 25 Juil 2017
Modifié(e) : per isakson
le 25 Juil 2017
"??? 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.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur 打印和保存 dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!