Testing Object inside and object
I'm writing an image processing application which recognizes objects based on their shapes. The issue that I'm facing is that since one object can be comp开发者_C百科osed of one or more subobjects eg. human face is an object which is composed of eyes, nose and mouth.
Applying image segmentation creates separate objects but does not tells whether one object is inside another object.
How can I check whether an object is contained inside another object effeciently.
For now my algoirthm is wat I would call 8 point test in which u chose 8 points at 8 corners and check whther all of them are inside the object.If they are in then u can more quite certain that entire object is inside another object... But it has got certain limitation or certain areas of failure...
Also just because inner object is inside another object means I should treat them to part of outer object????
One way to test whether one object is fully inside another is to convert both into binary masks using poly2mask (in case they aren't binary masks already), and to test that all pixels of one object are part of the other object.
%# convert object 1 defined by points [x1,y1] into mask
msk1 = poly2mask(x1,y1,imageSizeX,imageSizeY);
%# do the same for object 2
msk2 = poly2mask(x2,y2,imageSizeX,imageSizeY);
%# check whether object 1 is fully inside object 2
oneInsideTwo = all(msk2(msk1));
However, is this really necessary? The eyes should always be close to the center of the face, and thus, the 8-point-method should be fairly robust at identifying whether you found an eye that is part of the face or whether it is a segmentation artifact.
Also, if an eye is on a face, then yes, you would consider it as part of that face - unless you're analyzing pictures of people that are eating eyes, in which case you'd have to test whether the eye is in roughly the right position on the face.
In sum, the answer to your questions is a big "depends on the details of your application".
精彩评论