"Index in position 2 exceeds array bounds." - imfindcircles

1 次查看(过去 30 天)
Running the code:
I = imread('L1.tif');
[centersBright,radiiBright,metricBright] = imfindcircles(I,[10 30], ...
'ObjectPolarity','bright','Sensitivity',0.92,'EdgeThreshold',0.1);
xi = centersBright(:,1);
yi = centersBright(:,2);
P = impixel(I,xi,yi);
Intensity = P(:,1);
clearvars -except Intensity centersBright
It gives me the error message : "Index in position 2 exceeds array bounds.", and I do not know how to resolve it. I am expecting the funciton to identify ~7 circles.

回答(1 个)

Taylor
Taylor 2024-4-16
If you run this in a script, MATLAB will tell you exactly what line is yielding the error. You are trying to indexing to a position that is greater than the size of a particular dimension of a variable. For example, centersBright should be an mx2 array where m is the number of circles found. Let's say 7 circles were found, so centersBright is 7x2. If you were to index to centersBright(10,1) you would get a similar error because you are trying to reference to a tenth circle that does not exist.

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by