Postprocessing Module

Image refinement and enhancement tools

Overview

The postprocessing module provides tools for refining and enhancing the converted archaeological drawings, focusing on output quality and archaeological detail preservation.

Binarize Image

def binarize_image(
    image: Union[PIL.Image, np.ndarray],
    threshold: int = 127
) -> PIL.Image

Converts grayscale drawings to binary format, ideal for final publication preparation.

Parameters

image

Input image (PIL Image or numpy array)

threshold

Intensity threshold (0-255)

Examples

binary = binarize_image("processed_vessel.png", threshold=150)

Remove White Background

def remove_white_background(
    image: PIL.Image,
    threshold: int = 250
) -> PIL.Image

Creates transparent backgrounds for archaeological drawings, useful for figure composition.

Parameters

image

Input drawing

threshold

Value above which pixels are considered white

Examples

transparent = remove_white_background("vessel.png", threshold=245)

Process Image Binarize

def process_image_binarize(
    image_path: str,
    binarize_threshold: int = 127,
    white_threshold: int = 250,
    save_path: Optional[str] = None
) -> PIL.Image

Combined function for binarization and background removal.

Parameters

image_path

Path to input image

binarize_threshold

Threshold for black/white conversion

white_threshold

Threshold for transparency

save_path

Optional output path

Binarize Folder Images

def binarize_folder_images(
    input_folder: str,
    binarize_threshold: int = 127,
    white_threshold: int = 250
) -> None

Batch processes a folder of drawings, applying binarization and background removal.

Parameters

input_folder

Directory containing drawings

binarize_threshold

Threshold for binarization

white_threshold

Threshold for transparency

Enhance Stippling

def enhance_stippling(
    img: PIL.Image,
    min_size: int = 80,
    connectivity: int = 2
) -> Tuple[PIL.Image, PIL.Image]

Isolates and enhances stippling patterns in archaeological drawings.

Parameters

img

Input drawing

min_size

Minimum object size to preserve

connectivity

Connection parameter for pattern detection

Returns

Returns tuple containing: - processed_image: Drawing with enhanced stippling - stippling_pattern: Isolated stippling mask

Modify Stippling

def modify_stippling(
    processed_img: PIL.Image,
    stippling_pattern: PIL.Image,
    operation: str = 'dilate',
    intensity: float = 0.5,
    opacity: float = 1.0
) -> PIL.Image

Adjusts stippling patterns through morphological operations and intensity modulation.

Parameters

processed_img

Base image without stippling

stippling_pattern

Isolated stippling pattern

operation

Type of modification (‘dilate’, ‘fade’, or ‘both’)

intensity

Morphological modification strength (0.0-1.0)

opacity

Stippling opacity factor (0.0-1.0)

Examples

enhanced = modify_stippling(
    base_img,
    dots_pattern,
    operation='both',
    intensity=0.7,
    opacity=0.8
)

Control Stippling

def control_stippling(
    input_folder: str,
    min_size: int = 50,
    connectivity: int = 2,
    operation: str = 'fade',
    intensity: float = 0.5,
    opacity: float = 0.5
) -> None

Batch processes stippling patterns in a folder of archaeological drawings.

Parameters

input_folder

Directory containing drawings

min_size

Minimum object size to preserve

connectivity

Pattern detection parameter

operation

Modification type (‘dilate’, ‘fade’, ‘both’)

intensity

Modification strength

opacity

Pattern opacity

Examples

control_stippling(
    "vessel_drawings/",
    min_size=60,
    operation='both',
    intensity=0.6
)