2D Boundary Box in TD?

Hey, first time posting here :slight_smile:
I’m getting my head around 2D Boundary Box. Similar to “trim layer” from Adobe Photoshop.

The idea is to analyze the rectangle around an object.
This is my manual example:

as you can see - at the upper node its similar to “trim layer” thingy
at the bottom node its the boundary box

anyone have idea how to achieve it?

Hi @Rotem_Mor,

the solution I have here hinges on having a good alpha mask. In my example I also make use of the Banana and while it already comes with a good alpha channel, I added a threshold so this might work well with other custom imagery.
The basic Idea is that the Analyze TOP can retrieve the minimum or maximum individual pixel in an image. So if we can give every pixel in our image a position, we can retrieve the minimum and maximum position which results in our bounding box.

To ascribe position to a image, we multiply the image (already with the alpha channel) with a so called uv map - essentially a texture that is a vertical ramp in the red channel and a horizontal ramp in the green channel. Add 2 Analyze TOPs setting them to Minimum Pixel and Maximum Pixel respectively as well as setting the Analyze Channel parameter to “RGBA Independent” and the Mask paremter to “Alpha”. The 2 resulting images I combine with a Layout TOP and convert into a CHOP which finally holds the values I can use in the Crop TOP.

Hope this makes sense
cheers
Markus
base_bbox.tox (1.3 KB)

3 Likes

This is mind blowing.

1 Like

Incredible! Thank you so much!

I added second cropTOP to return the cropped part back in the frame.

Hi @Rotem_Mor,

could you just use a Fit TOP or Over TOP for this? Might be a simpler operation.

cheers
Markus


I only managed to get Fit TOP unevenly match to the original

Hi @Rotem_Mor,

ah - wasn’t clear what the intend was - sorry for misleading you.

cheers
Markus

1 Like