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],int = 127
threshold: -> 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
= binarize_image("processed_vessel.png", threshold=150) binary
Remove White Background
def remove_white_background(
image: PIL.Image,int = 250
threshold: -> 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
= remove_white_background("vessel.png", threshold=245) transparent
Process Image Binarize
def process_image_binarize(
str,
image_path: int = 127,
binarize_threshold: int = 250,
white_threshold: str] = None
save_path: Optional[-> 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(
str,
input_folder: int = 127,
binarize_threshold: int = 250
white_threshold: -> 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,int = 80,
min_size: int = 2
connectivity: -> 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,str = 'dilate',
operation: float = 0.5,
intensity: float = 1.0
opacity: -> 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
= modify_stippling(
enhanced
base_img,
dots_pattern,='both',
operation=0.7,
intensity=0.8
opacity )
Control Stippling
def control_stippling(
str,
input_folder: int = 50,
min_size: int = 2,
connectivity: str = 'fade',
operation: float = 0.5,
intensity: float = 0.5
opacity: -> 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/",
=60,
min_size='both',
operation=0.6
intensity )