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!