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)
current_value = 0.5;
step_value = 0.05;
preprocessed_image = im2double(raw_image);
binary_image = [];
...
function ok_button_callback(source, eventdata)
threshold_value = current_value;
close(handle_new_figure)
end
end