impixel fails when a function is called the second time.
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (1)
Douglas Brenner
le 17 Oct 2016
0 votes
1 commentaire
Guillaume
le 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.
Catégories
En savoir plus sur ROI-Based Processing 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!