How to have a user prompt window to submit real time values

Hi
I am using a Local Gaussian Distribution algorithm to auto segment some images.
This algorithm contains a few parameters as optimization parameters. A few of them are, kernel size, time step, number of iterations, outer/inner weight, length and data terms and more.
By tuning those parameters you get different segmentation results and different behaviour of the active contour.
What I need is a panel, with boxes (same number of boxes as the parameters), that the user shall be able to modify all those values while performing the auto segmentation. For instance, if a higher number of iterations are necessary then he/she shall go and adjust acordingly the Number of Iterations Box, and he can also experiement with the other boxes at the same time. The active contour should change behaviour and characteristics as the values are changing real time.
Is this possible?
Thanks

 Accepted Answer

@Stelios, The questions I've seen from you today could easily be answered by thinking a bit more about what you're doing and actually reading the documentation of the functions you use.
Using the debugger would also help you understand why the code you write doesn't work.
I'm not sure why you even expected the code you wrote to work:
%create a cell of char arrays
us = {'Iterations:','Time Step:', 'Kernel Size (sigma):', 'Data Term Weight'};
%convert that cell array of char arrays into a matrix
t = cell2mat(us); %could have used t = [us{:}];
After that, t is
>>t
t =
'Iterations:Time Step:Kernel Size (sigma):Data Term Weight'
You then have
e = str2num(t); %convert text to number
What do you expect to happen when t is the above?
>> e
e =
[]
So e is of course empty since the text does not represent a number. Of course, trying to index an empty matrix is always going to be an error.
I suspect that you meant to index i instead. Using variable names rather than single letters that have meaning would avoid you getting confused about which variable is which.

1 Comment

Thanks Guillaume but after some thorough reading I indeed managed to solve it. Thanks again for your contribution.
May you can answer me this last comment?

Sign in to comment.

More Answers (1)

What you are describing is an App Designer app. Very possible there.
Perhaps a quicker way if you are using a live script is to add interactive controls. Right now (r18b) there are two options: slider and dropdown.
If you just want a dialog box to appear, my suggestion would be to look into the inputdlg function, which allows you to create a dialog box to gather user input(s).

4 Comments

I use this line
x = inputdlg({'Iterations','Time Step','KerneL Size (sigma)', 'Data Term Weight'},...
'Input', [1 50; 1 12; 1 20; 1 100; ]);
How can I correlate the inputs with the algorithm parameters?
E.g.
NumbItera = 'Iterations'; ???
It won't accept it.
I get the error
Undefined operator '*' for input arguments of type 'cell'.
Error in ruller (line 160)
Ksigma=fspecial('gaussian',round(2*sigma)*2 + 1,sigma); % kernel
And similar other errors.
I use this line code now
us = {'Iterations:','Time Step:', 'Kernel Size (sigma):', 'Data Term Weight'};
t = cell2mat(us);
e = str2num(t);
numberOfLines = 4;
dialogTitle = 'Specify optimization parameters for LGD';
def = {'300', '0.1', '5', '20'};
U = inputdlg(us,dialogTitle,numberOfLines,def);
i = cellfun(@str2num,U);
Img = double(J(:,:,1));
NumIter = e(1); %iterations
timestep= 0.1; %time step
mu=0.1/timestep;% level set regularization term, please refer to "Chunming Li and et al. Level Set Evolution Without Re-initialization: A New Variational Formulation, CVPR 2005"
sigma = e(3);%size of kernel
epsilon = 1;
c0 = 2; % the constant value
lambda1=1.05;%outer weight, please refer to "Chunming Li and et al, Minimization of Region-Scalable Fitting Energy for Image Segmentation, IEEE Trans. Image Processing, vol. 17 (10), pp. 1940-1949, 2008"
lambda2=1.0;%inner weight
%if lambda1>lambda2; tend to inflate
%if lambda1<lambda2; tend to deflate
nu = 0.001*255*255;%length term
alf = e(4);%data term weight
I get the error
Index exceeds matrix dimensions.
Error in ruller (line 145)
NumIter = e(1); %iterations
Why?
The variable us does not contain the user inputs from the dialog box. Those are assigned to the variable U. The following lines of code appear to be unnecessary and can be removed.
t = cell2mat(us);
e = str2num(t);
Yes it's fixed that. Thank you very much. Can you please, check my new question and answer it ?

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!