File size: 2,703 Bytes
6bd3f77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python3
"""
Usage example for unified_tiff_to_512png.py

This script demonstrates how to use the XBDConverter class to convert
xBD TIFF files to 512x512 PNG files with different configurations.
"""

from unified_tiff_to_512png import XBDConverter

def example_basic_usage():
    """
    Basic usage example - converts all TIFF files to 512x512 PNG
    """
    print("=== Basic Usage Example ===")
    
    # Create converter with default settings
    converter = XBDConverter()
    
    # Run the full conversion pipeline
    converter.run_full_conversion(crop_size=512)
    print("Conversion completed!")

def example_custom_paths():
    """
    Example with custom input and output directories
    """
    print("=== Custom Paths Example ===")
    
    # Custom input and output directories
    input_dir = "/path/to/your/xview2_geotiff/geotiffs"
    output_dir = "/path/to/your/output/images-w512-h512"
    
    converter = XBDConverter(input_dir=input_dir, output_dir=output_dir)
    converter.run_full_conversion(crop_size=512)
    print("Custom path conversion completed!")

def example_different_crop_sizes():
    """
    Example showing how to create different crop sizes
    """
    print("=== Different Crop Sizes Example ===")
    
    converter = XBDConverter()
    
    # Create 256x256 images
    converter.run_full_conversion(crop_size=256)
    print("256x256 conversion completed!")
    
    # Create 128x128 images
    converter.run_full_conversion(crop_size=128)
    print("128x128 conversion completed!")

def example_step_by_step():
    """
    Example showing how to run each step individually
    """
    print("=== Step-by-Step Example ===")
    
    converter = XBDConverter()
    
    # Step 1: Restructure dataset
    print("Step 1: Restructuring dataset...")
    converter.restructure_dataset()
    
    # Step 2: Convert TIFF to PNG
    print("Step 2: Converting TIFF to PNG...")
    converter.convert_all_tif_to_png()
    
    # Step 3: Crop images
    print("Step 3: Cropping images...")
    converter.crop_all_images(crop_size=512)
    
    # Step 4: Organize pre/post images
    print("Step 4: Organizing pre/post images...")
    converter.organize_pre_post_images()
    
    print("Step-by-step conversion completed!")

if __name__ == "__main__":
    print("xBD TIFF to 512x512 PNG Converter - Usage Examples")
    print("=" * 50)
    
    # Uncomment the example you want to run:
    
    # example_basic_usage()
    # example_custom_paths()
    # example_different_crop_sizes()
    # example_step_by_step()
    
    print("\nTo run an example, uncomment the desired function call above.")
    print("Make sure to adjust paths according to your setup.")