Halcon - extract crate region

I'm having huge difficulties to extract the region of the black crate from this image.

My situation is this: the blue is a region that i have predefined as it is roughly where the crate has to be. I use it to reduce the domain of the image. The yellow is the result i need: a filled region of the crate itself, as precise as possible. I managed to extract the crate with the Saturation channel, but it includes too much from above the crate..

I tried R G B and H L S channels, combinig them between each other, but without success.. unfortunately I was not able to find a combination that extracts the crate reliably.

ATTENTION: in this picture there is the Blue crate behind.. but there can be any other crate. Also the black crate in front can have any height. I already sorted the situations where the front crate is blue or green, but for the black it is getting quite difficult...

Here is a Image with a low crate height...


  • I don’t think that it’s the right manner. I think it’s better to avoid the conveyor belt and the window where you can see the other basket. In a few words, you can use 2 domains: left and right. In every domain, you can search for the basket part and then detect the line borders (left, top1, top2, right). When you know these four lines (really only one top segment it’s necessary) you know where is the basket and you can reconstruct its region.

    enter image description here