Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
error-index must be a positive integer or logical.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am getting error
Attempted to access g(0,0); index must be a positive integer or logical.
Error in ==> Untitled6 at 19 g(y1,i) = 1;
can u please why i get thiserror
my code is
image=imread('door.jpg')
image=rgb2gray(image)
[image1 num] = bwlabel(image);
stats = regionprops(image1, 'BoundingBox');
g = image;
[M N] = size(stats);
for k = 1:M
for i = floor(stats(k).BoundingBox(1)):floor(stats(k).BoundingBox(1))+stats(k).BoundingBox(3)
for j = floor(stats(k).BoundingBox(2)):floor(stats(k).BoundingBox(2))+stats(k).BoundingBox(4)
x1 = floor(stats(k).BoundingBox(1));
y1 = floor(stats(k).BoundingBox(2));
g(y1,i) = 1;
g(y1+stats(k).BoundingBox(4),i) = 1;
g(j,x1) = 1;
g(j,x1+stats(k).BoundingBox(3)) = 1;
end
end
end
0 commentaires
Réponses (1)
Dr. Seis
le 9 Fév 2012
You need to ensure all of the indices are greater than 0. When you round things (using "floor") you must be encountering values in your "BoundingBox" that are between 0 and 0.5 - can you just add 1 to all your results, or use "ceil" instead?
0 commentaires
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!