Contour (outline) detection implemented with pure C# with NO external dependencies. Extract outer shapes and holes from textures, and generate precise vertex contours for pixel arts.Image Contours is a pure C# implementation of the Suzuki-Abe border following algorithm for Unity. It analyzes images and extracts both outer contours (outlines) and inner holes, including their hierarchical relationships.In addition to contour detection, the package provides a way to convert contour pixels into 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 onPure C# implementation: No native plugins or platform-specific dependenciesContour hierarchy support: Detects both outer contours and holes, with parent-child relationshipsContour vertex construction: Convert contour pixels into pixel-corner-based verticesConfigurable detection behavior: Supports 4-connected and 8-connected neighborhoodsFlexible foreground definition: Use alpha threshold or provide a custom predicateTypical Use CasesVisualizing outlines of sprites or texturesBuilding editor tools that operate on image shapesPreparing data for mesh generation or collision approximationExtracting regions for gameplay or AI systemsWhat's IncludedCore contour detection implementationContour/outline vertices constructionExample components for drawing:Contour linesContour vertices of pixel artsContour pixelsSample scene with configurable parametersFull source code with XML documentationNUnit test casesCore FeaturesImplementation of Suzuki-Abe border following algorithmSingle-pass contour detectionDetects both outer contours and holesHierarchical contour structure with parent-child relationshipsConfigurable pixel connectivity (4 or 8)Custom predicate support for foreground detectionBuilt-in alpha threshold detectionMip level support for Texture2DAutomatic coordinate conversion to Unity's Texture2D spaceAPI HighlightsContourDetector.FindContoursOpaque(): Detect contours from fully opaque pixelsContourDetector.FindContoursByAlpha(): Detect contours using an alpha thresholdContourDetector.FindContours(): Detect contours using a custom predicateContour.Pixels: Access ordered contour pixel coordinatesContour.ToPixelArtVertices(): Convert the contour pixels into vertices assuming that the image is a pixel artContour.BoundingBox: Compute the bounding rectangle of a contourContour.IsHole: Identify whether a contour represents a holeContour.Parent: Access contour hierarchyAbout Pixel Art VerticesThe ToPixelArtVertices() method converts contour pixels into a sequence of vertices that represent the precise contours, assuming each pixel is a square.Vertices correspond to pixel corners, not centersOutput forms a continuous loop suitable for rendering or geometry useThis can be helpful when working with pixel art, especially those sprites in very small sizes (such as 8x8 or 16x16), where contour pixels alone may not be sufficient to describe the visible shape.Sample ComponentsContourLineDrawerDraw contours in scene using Unity's LineRendererSupports pixel-center and pixel-art-vertex modeContourPixelDrawer:Draw contours directly onto texturesPixelArtVerticesDrawer:Draw contour vertices of a pixel art as dotsOptional filtering of hole contoursAdjustable colors for outer contours and holesAdjustable via Unity Editor InspectorTestingIncludes NUnit-based unit testsCovers typical scenarios such as:Simple shapesSingle pixelsNested contoursAlso includes tests for edge cases (e.g., empty input)Platform SupportWorks on all Unity platformsNo native plugins, shaders or external dependenciesCode & ExtensibilityWritten in clean, readable C#XML documentation includedSource code is fully accessible and can be modified to fit specific needsAI assistance was used during development for:Initial code generationDocumentation draftingUnit test generationAll generated content was reviewed and adjusted by the developer.The implementation was checked against the original Suzuki-Abe paper and tested across multiple scenarios.




