Info
This question is closed. Reopen it to edit or answer.
error-index must be a positive integer or logical.
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Dr. Seis
on 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 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!