U2Net Segmentation

This function block performs salient object detection and background removal. Use it to extract a clear foreground mask and to produce a segmented image where the background is removed.

πŸ“₯ Inputs

Image Any The input image to analyze (color or grayscale). Connect the image source you want to segment.

πŸ“€ Outputs

Image Gray Grayscale probability map / mask showing object likelihood.

Image Any Segmented image where background is removed using the mask.

πŸ•ΉοΈ Controls

Model Select between available U2Net variants (for example "U2Net (High Quality)" or "U2NetP (Fast)"). Choose higher quality for better masks or the fast model for speed.

Input Size Resize the model input. Smaller values increase speed; larger values improve detail at the cost of performance.

Threshold Controls binarization of the probability map to create the final mask. Increasing the threshold makes the mask stricter (fewer foreground pixels).

🎨 Features

  • Foreground extraction to produce a soft probability map and a binary mask.

  • Segmented color image output that keeps only the detected foreground.

  • Two model choices to trade off accuracy vs speed.

  • Adjustable preprocessing size and threshold for fine control.

πŸ“ Usage Instructions

  1. Connect an image source to the Image Any input.

  2. Choose a Model depending on whether you prefer quality or speed.

  3. Adjust Input Size to balance detail and processing time.

  4. Tune Threshold to get the desired binary mask (preview using a Show Image block).

  5. Use the Image Gray output when you need the mask for further processing, and the Image Any output for visualization or saving.

πŸ“Š Evaluation

When run, this block produces a probability mask and a segmented image based on the currently selected model and slider settings. Use the mask output to feed subsequent processing blocks (e.g., filtering, contour detection, ROI operations).

πŸ’‘ Tips and Tricks

  • To speed up processing while keeping acceptable quality, reduce Input Size and use the U2NetP (Fast) model.

  • For better-looking masks on noisy images, pass the source through Denoising or Blur before this block.

  • If the subject is small relative to the image, use Image Resize to upsample the region of interest before segmentation.

  • Preview results interactively by connecting the segmented output to Show Image.

  • Save results automatically by linking the segmented image to Image Logger or Image Write.

  • If you need alternative background removal approaches, compare results with Background Removal (RMBG-1.4) or Background Removal (BiRefNet) to see which fits your scene best.

  • Use the binary mask output as input to ROI or shape-analysis blocks (for example, contour finders or measurement blocks) to extract object geometry.

(hint: useful companion blocks β€” Show Image, Image Resize, Denoising, Image Logger, Image Write, Background Removal (RMBG-1.4), Background Removal (BiRefNet))

πŸ› οΈ Troubleshooting

  • If masks look incomplete or too noisy: increase Input Size or apply Denoising/Blur to the input image.

  • If the mask is too permissive (background included): raise Threshold to make the mask stricter.

  • If processing is too slow: switch to the faster model option and/or lower the Input Size.

  • If no output appears: confirm a valid image is connected to the Image Any input and preview using Show Image.

Last updated