SAM2 is remarkably good at understanding what you clicked on, but out of the box, its mask boundaries can look rough — jagged edges, staircase artifacts, and imprecise contours that break the illusion when you wobble an object. In this article, we’ll walk through the techniques WobblePic uses to improve segmentation accuracy and produce clean, smooth masks that make the wobble effect look natural.
The Problem: Staircase Boundaries
SAM2’s decoder outputs a low-resolution logits map — a 256×256 grid of confidence values, regardless of the original image size. To create a usable mask, this small grid needs to be upscaled to match the full image resolution.
The naive approach is nearest-neighbor upscaling: each pixel in the 256×256 grid is simply repeated to fill its corresponding block of pixels in the full-resolution image. This is fast, but it produces visible staircase artifacts along the mask boundary. When you wobble an object segmented this way, the blocky edges are obvious and distracting.
For an image viewer where visual quality matters, this isn’t good enough.
The Solution: Bilinear Logits Interpolation
WobblePic takes a different approach. Instead of upscaling the final binary mask, it upscales the raw logits (continuous confidence values) using bilinear interpolation before applying the threshold.
Here’s why this matters:
- Raw logits are continuous values (e.g., -2.3, 0.1, 4.7) that represent how confident SAM2 is that each pixel belongs to the object
- Bilinear interpolation smoothly blends between neighboring logit values, creating gradual transitions instead of hard steps
- After interpolation, the threshold is applied (typically logit > 0 = object), producing a mask with smooth, sub-pixel-accurate boundaries
The result is a mask boundary that follows the actual contour of the object rather than the 256×256 grid lines. Curved edges look curved. Fine details like hair or fur are preserved more faithfully.
Before (nearest-neighbor): After (bilinear logits):
┌──┬──┬──┐ ╭──────╮
│██│██│ │ │██████│
│██│██│██│ → │████████╮
│ │██│██│ ╰──██████│
└──┴──┴──┘ ╰────╯
Blocky staircase Smooth contour
This technique adds minimal computational cost — bilinear interpolation is lightweight compared to the SAM2 inference itself — but the visual improvement is significant.
Multiple Prompt Types for Better Selection
Accuracy isn’t just about mask boundaries. It’s also about selecting the right object in the first place. WobblePic supports multiple prompt types to give you control:
Point Prompt (Click)
The simplest approach — click on the object you want. SAM2 infers the object boundary from a single point. This works well for clearly defined objects but can be ambiguous when objects overlap or have complex shapes.
Box Prompt (Drag)
For more precise selection, drag a rectangle around the object. The bounding box gives SAM2 much more context about what you intend to select, especially helpful for:
- Objects close to other objects
- Elongated or irregularly shaped subjects
- Scenes where a point click might select a parent object (e.g., clicking a wheel selects the whole car)
Box prompts generally produce more accurate masks on the first try because they constrain the search space.
Interactive Refinement
Even the best AI model doesn’t always get it right on the first attempt. WobblePic lets you iteratively improve the selection:
- Shift + Click/Drag — Add to the current mask (include missed regions)
- Alt + Click/Drag — Remove from the current mask (exclude unwanted areas)
Each refinement operation sends additional prompts to SAM2, which recomputes the mask with the accumulated positive and negative cues. This means you can start with a rough selection and quickly refine it to exactly what you want.
Settings Panel: Selection Range
WobblePic’s Settings Panel includes a Selection Range slider that controls the mask threshold. This directly affects segmentation accuracy:
- Lower values — More conservative selection, only including high-confidence pixels. Good for hard-edged objects like electronics or geometric shapes.
- Higher values — More aggressive selection, capturing more of the object including uncertain boundary pixels. Good for soft-edged objects like fluffy animals or food with irregular surfaces.
By adjusting this slider, you can fine-tune the mask to match the specific characteristics of each image.
Conclusion
Improving segmentation accuracy in WobblePic is a combination of several techniques working together:
- Bilinear logits interpolation eliminates staircase artifacts at mask boundaries
- Box prompts provide more precise initial selection
- Interactive refinement lets you fine-tune any mask with Shift/Alt clicks
- Selection Range slider adapts the threshold to different image types
The result is segmentation that feels accurate, responsive, and visually clean — so when you wobble an object, the boundary looks natural and the effect is convincing.
Want to try it out? Download WobblePic and see the difference yourself, or check our tutorial for a step-by-step guide on using AI segmentation.