How to detect Hue from HSV image for individual objects

1 view (last 30 days)
Hi everyone, I was wondering how to detect the average hue value for a series of different objects. I've detected the bounding box for each object, from region props, and now wish to determine the hue value for the bounding box square.
Any help is greatly appreciated
for i=1:CC.NumObjects;
r=(groupdata(i).BoundingBox(2):groupdata(i).BoundingBox(2)+groupdata(i).BoundingBox(3));
c=(groupdata(i).BoundingBox(1):groupdata(i).BoundingBox(1)+groupdata(i).BoundingBox(3));
P{i} = HSVimage(:,:,1);
end

Accepted Answer

Walter Roberson
Walter Roberson on 27 Mar 2014
mean2(P{i}(r,c))
  3 Comments
Ian
Ian on 27 Mar 2014
No worries I worked it out, it works with the below. The error was not rounding. Thanks again.
for i=1:CC.NumObjects;
r{i}=(groupdata(i).BoundingBox(2):groupdata(i).BoundingBox(2)+groupdata(i).BoundingBox(3));
c{i}=(groupdata(i).BoundingBox(1):groupdata(i).BoundingBox(1)+groupdata(i).BoundingBox(3));
Pix{i} = HSVim(:,:,1);
r{i}=round(r{i});
c{i}=round(c{i});
MeanPixel{i}=mean2(Pix{i} (r{i}, c{i}));
hold on
end
Image Analyst
Image Analyst on 27 Mar 2014
Why are you messing with cell arrays? Why make it complicated? Just use regular numerical arrays.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!