Effacer les filtres
Effacer les filtres

imref2d error: Array indices must be positive integers or logical values.

1 vue (au cours des 30 derniers jours)
Zi Qing Chua
Zi Qing Chua le 4 Sep 2022
Hi everyone,
I'm trying to calculate the circles from my figure, but the code shows error.
Command window shows:
Array indices must be positive integers or logical values.
Error in trial0621 (line 12)
RI = imref2d(size(subtract),xWorldLimits,yWorldLimits);
when I run the code. Does somebody know how to fix the error? Thank you very much for the help.
Here's my code:
clc
xWorldLimits = [-960 960];
yWorldLimits = [-600 600];
blank1 = imread('C:\Users\zz\Desktop\sample images for matlab\backg.bmp');
data = imread('C:\Users\zz\Desktop\sample images for matlab\test1.bmp');
subtract = data-blank1;
enhance = imadjust(subtract,[0.001 0.03]);
gray = rgb2gray(enhance);
BW = imbinarize(gray,'global');
SE = strel("disk",3);
BW2 = imopen(BW,SE);
RI = imref2d(size(subtract),xWorldLimits,yWorldLimits);
imshow(BW2,RI);
[brightcenters,brightradii,brightmetric] = imfindcircles(BW2,[5 50],'ObjectPolarity','bright','sensitivity',0.85);
h = viscircles(brightcenters,brightradii);
hold on
grid on
plot(brightcenters(:,1),brightcenters(:,2),'+','LineWidth',1.5)
count = height(brightradii)
size = mean(brightradii)
Mx = mean(brightcenters(:,1))
stdevx = std(brightcenters(:,1))
My = mean(brightcenters(:,2))
stdevy = std(brightcenters(:,2))

Réponses (1)

Matt J
Matt J le 4 Sep 2022
You have hidden the size() command by creating avariable called "size".
size = mean(brightradii)

Catégories

En savoir plus sur Feature Detection and Extraction dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by