Metadata-Version: 2.4
Name: ImageBoundaryPointsGeneration
Version: 0.1.0.2.2
Summary: Uses OpenCV to find image ' region ' boundaries. Returns set of boundary points for further tweaking as needed.
Project-URL: Homepage, https://github.com/jpshankar/ImageBoundaryPointsGeneration
Project-URL: Issues, https://github.com/jpshankar/ImageBoundaryPointsGeneration/issues
Requires-Python: >=3.13
Description-Content-Type: text/markdown
Requires-Dist: flask>=3.1.3
Requires-Dist: flask-cors>=6.0.2
Requires-Dist: opencv-python>=4.13.0.92
Requires-Dist: pillow>=12.2.0
Requires-Dist: pytest>=9.0.3

# ImageBoundaryPointsGeneration takes an image..

.. identifies the " region " in it and returns a list of points bounding the region.

This is meant to be used with a procedural generation project that generates 2D tile maps from provided tile sets within specified regions. It facilitates specifying those regions by uploading pictures in which the specification is clearly present.

# Example: 

![Region picture](test_images/test_image.jpg)

The above is a region assembled from pieces I picked up at a fair.

Approximation is done by calling `RegionBordersApproximator.approximate`:

```Python
RegionBordersApproximator.approximate(base_image_data=base_image_data, base_image_width=400, base_image_height=300, min_canny_threshold=100, max_canny_threshold=200, min_segmenting_threshold=70, max_segmenting_threshold=255, contour_thickness=2)
```

* `base_image_data`: image in Base64
* `base_image_width`, `base_image_height`: image width/height
* `min_canny_threshold`, `max_canny_threshold`: Canny edge detection thresholds
* `min_segmenting_threshold`, `max_segmenting_threshold`: Image segmenting thresholds
* `contour_thickness`: thickness of lines drawn for region borders

Results are output as

```Python
@dataclass(frozen=True)
    class RegionBordersApproximation:
        border_points: dict[uuid4, Point]
        border_segments: tuple[RegionBordersApproximator.RegionBorderSegment]
```

`RegionBorderSegment.point_Id` values correspond to `border_points` keys.

# Examples (visual):

Borders highlighted:

![Region picture](border_image.jpg)

Borders & boundary points highlit:

![Region picture](border_points_image.jpg)

The idea is that the border points can be more finely, manually tweaked from this initial state. Future iterations will reliably automate that tweaking.
