Skip to main content

A Python library for generating ASCII art from images with advanced filtering capabilities

Project description

ASCII Art Library

A Python library for generating ASCII art from images with advanced filtering capabilities.

Features

  • Generate high-quality ASCII art from images
  • Sprite-based character rendering for better visual results
  • Edge detection using Difference of Gaussians (DoG) filtering
  • Configurable character sets and rendering parameters
  • Both programmatic API and command-line interface

Installation

pip install -e .

Usage

Command Line Interface

Generate ASCII art from an image:

ascii-art input.jpg -o output.png

Customize edge detection sensitivity:

ascii-art input.jpg --edge-threshold 70 -o output.png

Disable edge detection:

ascii-art input.jpg --no-edge -o output.png

Programmatic API

from ascii_art import SpriteASCIIGenerator
import cv2

# Create generator with default settings (edge detection enabled)
generator = SpriteASCIIGenerator()

# Load and process an image
img = cv2.imread("input.jpg")
ascii_img = generator.generate_ascii(img)

# Save result
cv2.imwrite("output.png", ascii_img)

Customize settings:

from ascii_art import SpriteASCIIGenerator
import cv2

# Create generator with custom settings
settings = {
    "use_edge": True,        # Enable edge detection (default: True)
    "edge_threshold": 70,    # Edge detection sensitivity (default: 90)
    "font_size": 8,          # Font size for characters (default: 8)
    "sharpness": 5,          # Image sharpness (default: 100)
    "white_point": 128       # White point threshold (default: 2)
}

generator = SpriteASCIIGenerator(settings)

# Load and process an image
img = cv2.imread("input.jpg")
ascii_img = generator.generate_ascii(img)

# Save result
cv2.imwrite("output.png", ascii_img)

Configuration

You can customize the ASCII art generation by passing settings to the generator:

settings = {
    "use_edge": True,        # Enable edge detection
    "edge_threshold": 90,    # Edge detection threshold
    "font_size": 8,          # Font size for characters
    "sharpness": 5,          # Image sharpness
    "white_point": 128       # White point threshold
}

generator = SpriteASCIIGenerator(settings)

API Reference

SpriteASCIIGenerator

Main class for generating ASCII art using sprite-based approach.

Methods

  • __init__(settings): Initialize the generator with settings
  • generate_ascii(img): Generate ASCII art from an image

DoGFilter

Difference of Gaussians filter for edge detection.

Methods

  • __init__(settings): Initialize the filter with settings
  • difference_of_gaussian(image): Apply DoG filter to an image
  • flow_dog(image): Apply flow-based DoG filtering

Requirements

  • Python 3.11+
  • OpenCV
  • NumPy
  • Pillow
  • SciPy

License

MIT

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

adhipk_ascii_art-0.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

adhipk_ascii_art-0.1.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file adhipk_ascii_art-0.1.0.tar.gz.

File metadata

  • Download URL: adhipk_ascii_art-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.9

File hashes

Hashes for adhipk_ascii_art-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7584977d26b8d34e12ee8afe9b6bab555a150c43d87e55339dacb4506d41332d
MD5 de871db1e15d308377278636101586ad
BLAKE2b-256 c9fb64afda52dbeb65a94e13c5865fcc03536bbe53274e16e8837b96b43c2d4e

See more details on using hashes here.

File details

Details for the file adhipk_ascii_art-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for adhipk_ascii_art-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b9a74334778bb7d3ecaa83dd2025aac02055b74a874ae28090f2eee5ccd3419
MD5 33f8b243542165ed240a65fa8f104f18
BLAKE2b-256 299d8f67586651f34ccfd2886e8c83b366c2291a1ad2b3f9ae6d23a8ec5dfe8d

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