A downloadable unity package

Buy Now$15.00 USD or more

Image Contours is a pure C# implementation of the Suzuki-Abe border following algorithm for Unity. It analyzes images and extracts outer contours and inner holes.

This package helps when you need to programmatically understand image shapes—whether you're highlighting shape outlines, creating editing tools, or building systems that need to work with image boundaries.

What makes it special:

  • 100% C# implementation - No native plugins, works on any Unity platform (Windows, Mac, Linux, iOS, Android, WebGL, consoles)
  • Hierarchical contour detection - Automatically identifies holes and parent-child relationships
  • Flexible pixel classification - Use built-in alpha threshold detection or provide your own predicate to define what counts as foreground
  • Connectivity options - Choose between 4-connected or 8-connected pixel neighborhoods
  • Production-ready - Extensively tested with comprehensive unit test coverage
  • Easy integration - Clean API that's easy to understand and extend for your specific needs

Typical Use Cases:

  • Detect texture outlines for highlighting or selection systems
  • Build tools that need to know where pixels are in a sprite
  • Extract boundaries for pathfinding or AI systems

What's Included:

  • Core contour detection implementation
  • Two visualization examples: LineRenderer-based and pixel-based drawing
  • One sample scene demonstrating different parameter configurations
  • Full source code with detailed comments and XML documentation
  • Unit test suite for validation

The package includes example components that show how to visualize detected contours. All code is documented and designed to be easy to understand and extend for your specific needs.

Technical Details

Core Features:

  • Pure C# implementation of Suzuki-Abe border following algorithm
  • Single-pass contour detection algorithm
  • Detects both outer contours and internal holes
  • Hierarchical contour organization with automatic parent-child relationships
  • Configurable pixel connectivity (4-connected or 8-connected)
  • Custom predicate support for flexible pixel classification
  • Built-in alpha threshold detection for convenience
  • Mip level support for multi-resolution processing
  • Coordinate system automatically converted to Unity's Texture2D convention

API Highlights:

  • ContourDetector.FindContoursOpaque() - Detect contours from fully opaque pixels
  • ContourDetector.FindContoursByAlpha() - Threshold-based contour detection
  • ContourDetector.FindContours() - Custom predicate-based detection for full control
  • Contour.Points - Access detected contour point coordinates
  • Contour.BoundingBox - Get contour bounding rectangle
  • Contour.IsHole - Identify hole vs. outer contours
  • Contour.Parent - Navigate contour hierarchy

Sample Components:

  • ContourLineDrawer - Visualize contours using Unity LineRenderer
  • ContourPixelDrawer - Draw contours directly on texture pixels
  • Configurable visualization colors for outer contours and holes
  • Optional hole filtering for simplified visualization
  • Real-time parameter adjustment in Unity Editor

Testing:

  • Comprehensive unit test coverage with NUnit
  • Tests validate algorithm correctness across various scenarios
  • Edge cases thoroughly tested (empty images, single pixels, nested holes, etc.)

Platform Support:

  • All Unity platforms supported (pure managed code)
  • No platform-specific native dependencies

Code Quality:

  • Clean, maintainable C# code
  • Extensive XML documentation comments
Published 21 hours ago
StatusReleased
CategoryTool
AuthorZhixiang
Tags2D, sourcecode, Unity
AI DisclosureAI Assisted, Code, Text

Purchase

Buy Now$15.00 USD or more

In order to download this unity package you must purchase it at or above the minimum price of $15 USD. You will get access to the following files:

ImageContours1.0.0.unitypackage 265 kB

Development log

Leave a comment

Log in with itch.io to leave a comment.