Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
error-index must be a positive integer or logical.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Dr. Seis
am 9 Feb. 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 Kommentare
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!