Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Principle:Obss Sahi Image Slicing

From Leeroopedia


Knowledge Sources
Domains Object_Detection, Computer_Vision, Image_Processing
Last Updated 2026-02-08 12:00 GMT

Overview

A tiling technique that partitions high-resolution images into overlapping sub-windows (slices) to enable detection of small objects that would otherwise be missed at the full image scale.

Description

Image slicing (also called tiling or patching) addresses a fundamental limitation of object detection models: they operate at fixed input resolutions, so small objects in high-resolution images receive very few pixels after resizing and become undetectable.

By dividing a large image into smaller overlapping patches, each patch can be processed at the detector's native resolution, giving small objects enough pixel coverage for reliable detection. The overlap between adjacent slices ensures objects straddling slice boundaries are fully captured by at least one slice.

SAHI's slicing approach supports:

  • Fixed-size slicing: User specifies slice height, width, and overlap ratios
  • Auto-resolution slicing: Slice dimensions are automatically calculated based on image resolution and aspect ratio, categorizing images as low/medium/high/ultra-high resolution

The output is a SliceImageResult containing the cropped image patches, their pixel coordinates in the original image (for later coordinate remapping), and optionally sliced COCO annotations for training dataset preparation.

Usage

Use image slicing whenever performing object detection on images where the target objects are small relative to the image dimensions. This is particularly important for:

  • Aerial and satellite imagery
  • Surveillance camera feeds
  • Medical imaging (histopathology)
  • Any scenario where objects of interest occupy less than ~1% of the total image area

Slicing is the second step in the SAHI inference pipeline, after model initialization and before per-slice detection.

Theoretical Basis

The core algorithm is a sliding window approach with configurable overlap:

# Pseudocode for slice grid computation
def compute_slice_grid(image_h, image_w, slice_h, slice_w, overlap_h, overlap_w):
    slices = []
    y = 0
    while y < image_h:
        x = 0
        while x < image_w:
            x2, y2 = min(x + slice_w, image_w), min(y + slice_h, image_h)
            x1, y1 = max(0, x2 - slice_w), max(0, y2 - slice_h)
            slices.append([x1, y1, x2, y2])
            x += slice_w - overlap_w
        y += slice_h - overlap_h
    return slices

Auto-resolution calculation:

The image resolution factor is computed as f=log2(H×W), then mapped to slice parameters:

Factor Range Resolution Class Slice Strategy
f <= 18 Low (e.g. 640x640) No slicing (single tile)
18 < f <= 21 Medium (e.g. 1024x1024) 1-2 splits, 80% overlap
21 < f <= 24 High (e.g. 2048x2048) 4 splits, 40% overlap
f > 24 Ultra-high (e.g. 4096x8192) 8+ splits, 40% overlap

Orientation (landscape vs portrait) adjusts the row/column split ratio.

Related Pages

Implemented By

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment