https://github.com/bobld/pcontournet
C# library for finding contours in binary images. Ported from https://github.com/LingDong-/PContour
https://github.com/bobld/pcontournet
Last synced: 5 months ago
JSON representation
C# library for finding contours in binary images. Ported from https://github.com/LingDong-/PContour
- Host: GitHub
- URL: https://github.com/bobld/pcontournet
- Owner: BobLd
- License: mit
- Created: 2024-07-28T08:12:46.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-10T12:08:35.000Z (almost 2 years ago)
- Last Synced: 2025-11-03T22:25:24.453Z (9 months ago)
- Language: C#
- Homepage:
- Size: 23.4 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# PContourNet
C# library for finding contours in binary images. Ported from java to C# from https://github.com/LingDong-/PContour
### From original README:
Similar to OpenCV's `cv::findContours` and `cv::approxPolyDP`, the algorithms implement the following papers:
- Suzuki, S. and Abe, K., Topological Structural Analysis of Digitized Binary Images by Border Following
- David Douglas and Thomas Peucker, Algorithms for the reduction of the number of points required to represent a digitized line or its caricature
## Usage
```csharp
int[] bitmap = new int[]
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 1, 0, 0,
0, 1, 1, 1, 1, 1, 0, 0,
0, 1, 1, 0, 0, 1, 1, 0,
0, 1, 1, 0, 0, 1, 1, 0,
0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
int width = 8;
int height = 8;
// find contours
var contours = PContour.FindContours(bitmap, width, height);
// simplify the polyline
for (int i = 0; i < contours.Count; i++)
{
contours[i].points = PContour.ApproxPolyDP(contours[i].GetPointsSpan(), 1).ToArray().ToList();
}
```