Replace specific rectangular regions with ones
이전 댓글 표시
I wanted to fill the rectangular positions in bbox (values attached in order - [x y width height]) with ones.
I tried the below code, but i dont get any white regions, what can be the reason?
mask = zeros(300,950);
load bbox
for i = length(bbox)
mask(bbox(i,1) : bbox(i,3) , bbox(i,2) : bbox(i,4)) = 1;
end
figure, imshow(mask);
댓글 수: 3
Johannes Hougaard
2021년 7월 7일
I don't think you can index using e.g. 31.5 as your index.
Indices must be integers.
Ben McMahon
2021년 7월 7일
편집: Ben McMahon
2021년 7월 7일
Your loop is currently only setting the counter to the final value. To loop over all i in a set use the : notation. For example:
for i = 1:length(bbox)
mask( bbox(i,1) : bbox(i,3) , bbox(i,2) : bbox(i,4) ) = 1;
end
Elysi Cochin
2021년 7월 9일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Region and Image Properties에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!