Skip to main content

Simple outline mapper for images, using color clustering

Project description

OutlineMapper

Simple outline mapper for images, using color clustering.

Installation

You can install the package using pip:

pip install OutlineMapper

Usage

from outline_mapper import process_image
import matplotlib.pyplot as plt

image_path = 'path/to/your/image.png'
threshold = 0.04
min_pixels = 100
n_clusters = 5

# Get the image with black outlines
outlined_image = process_image(image_path, threshold, min_pixels, n_clusters, return_format="outlined_image")

# Get the mask
mask = process_image(image_path, threshold, min_pixels, n_clusters, return_format="mask")

# Get the image with colored zones
colored_zones = process_image(image_path, threshold, min_pixels, n_clusters, return_format="colored_zones")

# Get the image with colored zones and black outlines
colored_zones_with_outlines = process_image(image_path, threshold, min_pixels, n_clusters, return_format="colored_zones_with_outlines")

# Display the results
plt.figure(figsize=(24, 6))

plt.subplot(1, 4, 1)
plt.imshow(outlined_image)
plt.title('Original Image with Outlines')
plt.axis('off')

plt.subplot(1, 4, 2)
plt.imshow(mask)
plt.title('Mask with Outlines')
plt.axis('off')

plt.subplot(1, 4, 3)
plt.imshow(colored_zones)
plt.title('Colored Zones')
plt.axis('off')

plt.subplot(1, 4, 4)
plt.imshow(colored_zones_with_outlines)
plt.title('Colored Zones with Outlines')
plt.axis('off')

plt.show()

parameters

Parameters:

  • image_path (str): Path to the image file.
  • threshold (float): Threshold for color similarity.
  • min_pixels (int): Minimum number of pixels for a zone.
  • n_clusters (int): Number of clusters for K-means.
  • return_format (str): Format of the returned image. Options are "outlined_image", "mask", "colored_zones", and "colored_zones_with_outlines".

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

OutlineMapper-0.1.3.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

OutlineMapper-0.1.3-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

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