Show the object in boundary box
5 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Image Analyst
on 6 Feb 2018
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 Comments
See Also
Categories
Find more on Computer Vision with Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!