Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
error-index must be a positive integer or logical.
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Dr. Seis
2012년 2월 9일
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
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!