Show the object in boundary box
조회 수: 5 (최근 30일)
이전 댓글 표시
I'm trying to use boundary box for each objects and then calculate color histogram for each object !
Here in my code, I tried to show the object which is "white square"
[row , col ] = size (bbox);
for i =1 : row
x = bbox(i,1);
y =bbox(i,2);
w=bbox(i,3);
h=bbox(i,4);
TestImage = OriginalImage(x:(x+w), y:(y+h),:);
r = TestImage(:,:,1);
g = TestImage(:,:,2);
b = TestImage(:,:,3);
subplot(2,2,3)
imshow(TestImage);
end
but the result isn't what I expected, see the image ! Any advice please :)

댓글 수: 0
답변 (1개)
Image Analyst
2018년 2월 6일
This is a very common beginner mistake.
You think arrays are indexed as OriginalImage(x, y). They ARE NOT. They are indexed as OriginalImage(row, column), which is OriginalImage(y, x). Reverse your indexes:
TestImage = OriginalImage(y:(y+h), x:(x+w), :);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!