Skip to main content

Uses OpenCV to find image ' region ' boundaries. Returns set of boundary points for further tweaking as needed.

Project description

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

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

Approximation is done by calling RegionBordersApproximator.approximate:

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

@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

Borders & boundary points highlit:

Region picture

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imageboundarypointsgeneration-0.1.0.2.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file imageboundarypointsgeneration-0.1.0.2.2.tar.gz.

File metadata

File hashes

Hashes for imageboundarypointsgeneration-0.1.0.2.2.tar.gz
Algorithm Hash digest
SHA256 ab9eeb7a3a56a3a114f2789c115dcdcbcb2c1c0f07ca33434c92602a007af61c
MD5 b3e90e4acff4bc6d7e4d2c69923eb246
BLAKE2b-256 bfa8b0cac923a2dc79ad13ac98cda3889955378f9290100e549505d6d27d083f

See more details on using hashes here.

File details

Details for the file imageboundarypointsgeneration-0.1.0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for imageboundarypointsgeneration-0.1.0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d025d42129942841291a1c0ffe9da9ab32d72b364cdc4a57498323789bc3e2e7
MD5 78c8b6a38bbcc73dc5e6c6fbb1c00c6a
BLAKE2b-256 3da9f0bdef3c19780d321b70289d4a43058f814987e5424aee19c65ac9421faa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page