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

7 views (last 30 days)
Hanne
Hanne on 16 Apr 2024 at 13:07
Answered: Taylor on 16 Apr 2024 at 14:04
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.

Answers (1)

Taylor
Taylor on 16 Apr 2024 at 14:04
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.

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!