impixel fails when a function is called the second time.
Show older comments
Impixel doesn't work the second time.
CENTER = 0;
[X,Y,MAX]=getcenter(MA,x,y)
if (MAX > CENTER)
[X,Y,MAX] = getcenter(MAX,X,Y);
CENTER = MAX;
end
function [X,Y,MAX] = getcenter(MA,X,Y)
value = impixel(MA,X,Y); % FAILS HERE WHEN getcenter is called the second time.
for i = -5:5
for j = -5:5
temp = impixel(MA, X + i,Y + j);
if temp > value
value = temp;
X = X + i;
Y = Y + j;
end
end
end
MAX = value;
The function getcenter fails the second time around at impixel. Error using interp2>makegriddedinterp (line 237) Interpolation requires at least two sample points in each dimension. Consider using INTERP1 if X or Y have constant coordinates that can be eliminated to reduce the dimension.
Error in interp2 (line 128)
F = makegriddedinterp({X, Y}, V, method,extrap);
Error in impixel (line 106)
rgb = interp2(xx,yy,a,xi,yi,'*nearest');
Error in getcenter (line 2)
value = impixel(MA,X,Y);
Error in MAflow (line 17)
[X,Y,MAX] = getcenter(MAX,X,Y);
ideas? thanks
Accepted Answer
More Answers (1)
Douglas Brenner
on 17 Oct 2016
0 votes
1 Comment
Guillaume
on 17 Oct 2016
In general abbreviations make for poor variable names as they don't mean the same thing to all readers. It can mean microanuryem (?), master of arts, Massachusetts, mega ampere, etc.
In this case, it's also too specific, the function works with any image.
See how much more descriptive and self-documenting the variable names are in my code.
Categories
Find more on ROI-Based Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!