Image Contours is a pure C# implementation of the Suzuki-Abe border following algorithm for Unity. It analyzes images and extracts both outer contours and inner holes, including their hierarchical relationships.
In addition to contour detection, the package provides a way to convert contour pixels into pixel-aligned boundary vertices, which can be useful when working with pixel art or grid-based geometry.
This package is intended for developers who need direct access to image shape data for rendering, tooling, or geometry generation.
This package focuses on
- Pure C# implementation: No native plugins or platform-specific dependencies
- Contour hierarchy support: Detects both outer contours and holes, with parent-child relationships
- Pixel boundary reconstruction: Convert contour pixels into corner-based boundary vertices
- Configurable detection behavior: Supports 4-connected and 8-connected neighborhoods
- Flexible foreground definition: Use alpha threshold or provide a custom predicate
Typical Use Cases
- Visualizing outlines of sprites or textures
- Generating boundaries for pixel art assets
- Building editor tools that operate on image shapes
- Preparing data for mesh generation or collision approximation
- Extracting regions for gameplay or AI systems
What's Included
- Core contour detection implementation
- Pixel boundary reconstruction
- Example components for visualization:
- LineRenderer-based drawing
- Pixel-based drawing
- Sample scene with configurable parameters
- Full source code with XML documentation
- NUnit test cases