??? Output argument "feature" (and maybe others) not assigned during call to...

Problem occurs only when same function is used twice in one .m file.
First I define function mser. It is define correctly, and output variables are properly initialized.
When I wrote test script to test same function for different inputs, problem occurs. When I call function first time, it works correctly. When I call it another time, it crashes with comment:
??? Output argument "feature" (and maybe others) not assigned during call to...
Variable "feature" is output of "mser" function. It is not used anywhere in test script. Funny, when I simply split code in two (first part call of function 'mser' for one input, and second part for other input), both test scripts work!
After searching the Internet I found that this kind of error occur, in most, because of bad initialization (or no initialization at all), which in not the case in this function.
Why problem occurs?

Answers (2)

Hi,
could you please post some code which forces this error? I could not reproduce this at all.

2 Comments

%%--
Test script
%%--
clear all
a = imread('cameraman.tif');
[ out1, len1] = mserf(a);
ficeri1 = cat(1, out1(:).origin);
figure(1)
imshow(a);
hold on
plot( ficeri1(:,1), ficeri1(:,2), 'r*')
hold off
% split comes here
b = mat2gray( a, [256 0]);
[ out2, len2] = mserf(b);
ficeri2 = cat(1, out2(:).origin);
figure(2)
imshow(b);
hold on
plot( ficeri2(:,1), ficeri2(:,2), 'r*')
hold off
figure(3)
imshow(a)
This code does not call a function called "mser", but "mserf". Therefore the shown code dos not match your description. Please clarify this. The most important part of the error message is cut and replaced by "...".
The problem is, that the mser (or mserf) function does not create the output "feature" (btw. the name shadows a built-in function - better use another name!). So the interesting part is this function, not the caller. Please edit your original question and do *not* append the code as a comment of an answer.

Sign in to comment.

function:
function a = foo()
A = 1;
end
Now call it
>> out = foo
Error in ==> foo at 2
b = 1;
??? Output argument "a" (and maybe others) not assigned during call to
"C:\Users\Oleg\Desktop\foo.m>foo".

Asked:

on 8 Jul 2011

Community Treasure Hunt

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

Start Hunting!