impixel fails when a function is called the second time.
显示 更早的评论
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
采纳的回答
更多回答(1 个)
Douglas Brenner
2016-10-17
0 个投票
1 个评论
Guillaume
2016-10-17
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.
类别
在 帮助中心 和 File Exchange 中查找有关 ROI-Based Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!