tileflow


Nametileflow JSON
Version 0.6.0 PyPI version JSON
download
home_pageNone
SummaryFast, memory-efficient image tiling and reconstruction for deep learning and scientific computing
upload_time2025-08-15 16:11:32
maintainerTileFlow Contributors
docs_urlNone
authorTileFlow Contributors
requires_python>=3.13
licenseMIT License Copyright (c) 2025 Mantalys France, SAS Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords computer-vision deep-learning image-processing memory-efficient scientific-computing tiling
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TileFlow

> **High-performance tile-based image processing for scientific computing**

Process gigapixel images with minimal memory footprint through intelligent tiling and reconstruction. Designed for microscopy, whole-slide imaging, and large-scale computer vision workflows.

[![Python 3.13+](https://img.shields.io/badge/python-3.13+-blue.svg)](https://www.python.org/downloads/)
[![NumPy](https://img.shields.io/badge/numpy-2.2.0+-orange.svg)](https://numpy.org/)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)

## ๐Ÿš€ Key Features

- **๐Ÿง  Memory Efficient**: Process images larger than RAM using intelligent tiling
- **๐Ÿ”ฌ Multi-Channel Ready**: Native CHW format support for microscopy workflows  
- **โšก Zero-Copy Views**: Leverages numpy slicing for maximum performance
- **๐Ÿ”ง Seamless Reconstruction**: Intelligent overlap handling eliminates artifacts
- **โ˜๏ธ Cloud-Scale**: Built-in zarr integration for massive datasets
- **๐ŸŽฏ Pluggable Pipeline**: Custom processing functions integrate seamlessly

## ๐Ÿ“ฆ Installation

```bash
pip install tileflow
```

## ๐Ÿ”ฅ Quick Start

### Basic Image Processing

```python
from tileflow import TileFlow
import numpy as np

# Define your processing function
def enhance_contrast(tile):
    """Enhance contrast using histogram stretching."""
    p2, p98 = np.percentile(tile, (2, 98))
    return np.clip((tile - p2) / (p98 - p2 + 1e-8), 0, 1)

# Configure and run processor
processor = TileFlow(tile_size=(256, 256), overlap=(16, 16))
processor.configure(function=enhance_contrast)
result = processor.run(large_image)
```

### Multi-Channel Microscopy

```python
from tileflow import generate_multichannel_image, SobelEdgeDetector

# Generate realistic 8-channel microscopy data [C, H, W]
image_chw = generate_multichannel_image(shape=(8, 2048, 2048))

# Process DAPI channel for nuclei detection
dapi_channel = image_chw[0]  # Extract nuclei channel
sobel = SobelEdgeDetector(tile_size=(256, 256), overlap=(16, 16))
nuclei_edges = sobel.process(dapi_channel)

# Apply different processing to each channel
for i, channel in enumerate(image_chw):
    if i == 0:  # DAPI - nuclei segmentation
        processed = sobel.process(channel)
        nuclei_mask = processed > np.percentile(processed, 95)
    else:  # Other channels - generic enhancement
        processed = sobel.process(channel)
    
    print(f"Channel {i}: {processed.max():.3f} max intensity")
```

### Zarr for Massive Datasets

```python
import zarr
import numpy as np
from tileflow import TileFlow

# Create zarr dataset for efficient storage
dataset = zarr.open('microscopy.zarr', mode='w', 
                   shape=(16, 8192, 8192), chunks=(1, 1024, 1024))

# Process channels individually to manage memory
processor = TileFlow(tile_size=(512, 512), overlap=(32, 32))
processor.configure(function=your_analysis_function)

for channel_idx in range(16):
    # Load single channel from zarr (memory efficient)
    channel_data = np.array(dataset[channel_idx])
    
    # Process with TileFlow
    result = processor.run(channel_data)
    
    # Save or analyze result
    print(f"Channel {channel_idx} processed: {result.shape}")
```

## ๐Ÿงช Advanced Examples

### Custom Multi-Channel Pipeline

```python
class NucleiSegmentationPipeline:
    """Specialized pipeline for DAPI nuclei segmentation."""
    
    def __init__(self, sensitivity=0.95):
        self.sensitivity = sensitivity
        self.processor = TileFlow(tile_size=(256, 256), overlap=(16, 16))
    
    def segment_nuclei(self, tile):
        """Apply Sobel + thresholding for nuclei detection."""
        # Sobel edge detection
        gx = np.gradient(tile, axis=1)
        gy = np.gradient(tile, axis=0) 
        edges = np.sqrt(gx*gx + gy*gy)
        
        # Adaptive thresholding
        threshold = np.percentile(edges, self.sensitivity * 100)
        return (edges > threshold).astype(np.uint8)
    
    def process(self, dapi_channel):
        """Process DAPI channel for nuclei segmentation."""
        self.processor.configure(function=self.segment_nuclei)
        return self.processor.run(dapi_channel)

# Use the pipeline
pipeline = NucleiSegmentationPipeline(sensitivity=0.95)
nuclei_mask = pipeline.process(image_chw[0])
print(f"Detected {nuclei_mask.sum()} nuclei pixels")
```

### Concurrent Multi-Channel Processing

```python
from concurrent.futures import ThreadPoolExecutor
from tileflow import SobelEdgeDetector

def process_channel_pair(args):
    """Process a single channel with appropriate algorithm."""
    channel_idx, channel_data = args
    
    if channel_idx == 0:  # DAPI
        processor = NucleiSegmentationPipeline()
        return channel_idx, processor.process(channel_data)
    else:  # Other channels
        sobel = SobelEdgeDetector()
        return channel_idx, sobel.process(channel_data)

# Process multiple channels concurrently
with ThreadPoolExecutor(max_workers=4) as executor:
    tasks = [(i, image_chw[i]) for i in range(8)]
    futures = [executor.submit(process_channel_pair, task) for task in tasks]
    
    results = {}
    for future in futures:
        channel_idx, result = future.result()
        results[channel_idx] = result
        print(f"โœ“ Channel {channel_idx} complete")
```

## ๐ŸŽฏ Use Cases

| Domain | Application | Image Size | Channels |
|--------|-------------|------------|----------|
| ๐Ÿ”ฌ **Microscopy** | Fluorescence imaging, pathology | 2K-16K | 4-32 |
| ๐Ÿง  **Deep Learning** | Model inference, preprocessing | 1K-8K | 1-3 |
| ๐Ÿ›ฐ๏ธ **Remote Sensing** | Satellite analysis, multispectral | 4K-32K | 8-256 |
| ๐Ÿ“ฑ **Computer Vision** | Panoramic stitching, high-res analysis | 2K-16K | 1-4 |

## ๐Ÿ“Š Performance Benchmarks

| Dataset | Memory Usage | Processing Time | Zarr Compression |
|---------|--------------|-----------------|------------------|
| 2K ร— 2K ร— 8ch | 128 MB | 2.1s | 77% reduction |
| 4K ร— 4K ร— 16ch | 256 MB | 8.4s | 75% reduction |
| 8K ร— 8K ร— 32ch | 512 MB | 33.2s | 76% reduction |
| 16K ร— 16K ร— 8ch | 1.2 GB | 45.6s | 78% reduction |

*Consumer hardware (16GB RAM, 8-core CPU) with Sobel edge detection*

## ๐Ÿ” Enhanced Monitoring & Callbacks

TileFlow provides a comprehensive callback system for monitoring processing performance, memory usage, and energy consumption:

### Progress & Performance Tracking

```python
from tileflow import TileFlow, ProgressCallback, MetricsCallback

# Basic progress tracking
processor = TileFlow(tile_size=(256, 256), overlap=(32, 32))
processor.configure(function=your_function)

progress = ProgressCallback(verbose=True, show_rate=True)
metrics = MetricsCallback(verbose=True)

result = processor.run(image, callbacks=[progress, metrics])
```

### Memory Usage Monitoring

```python
from tileflow import MemoryTracker

# Track memory usage during processing
memory_tracker = MemoryTracker(detailed=True)
result = processor.run(large_image, callbacks=[memory_tracker])

# Get detailed statistics
memory_stats = memory_tracker.get_memory_stats()
print(f"Peak memory: {memory_stats['peak_delta_bytes'] / 1024**2:.1f} MB")
```

### Energy Consumption Tracking

```python
from tileflow import CodeCarbonTracker

# Track COโ‚‚ emissions (requires: pip install codecarbon)
carbon_tracker = CodeCarbonTracker(
    project_name="my-analysis",
    output_dir="./carbon_logs"
)

result = processor.run(image, callbacks=[carbon_tracker])
emissions = carbon_tracker.get_emissions_data()
print(f"COโ‚‚ emissions: {emissions['emissions_kg']:.6f} kg")
```

### Comprehensive Monitoring Suite

```python
from tileflow import CompositeCallback, ProgressCallback, MemoryTracker, CodeCarbonTracker

# Combine multiple monitoring callbacks
monitoring_suite = CompositeCallback([
    ProgressCallback(verbose=True),
    MemoryTracker(detailed=False),
    CodeCarbonTracker(project_name="scientific-analysis")
])

result = processor.run(image, callbacks=[monitoring_suite])
```

### Custom Scientific Callbacks

```python
from tileflow import TileFlowCallback

class ImageQualityCallback(TileFlowCallback):
    """Custom callback for scientific image analysis."""
    
    def on_tile_end(self, tile, tile_index, total_tiles):
        # Analyze each processed tile
        data = tile.image_data[0]
        snr = np.mean(data) / np.std(data)
        self.quality_metrics.append(snr)
    
    def on_processing_end(self, stats):
        print(f"Average SNR: {np.mean(self.quality_metrics):.2f}")

processor.run(image, callbacks=[ImageQualityCallback()])
```

## ๐Ÿ“š Complete Examples

Run comprehensive examples from the `scripts/` directory:

```bash
# Basic CHW format processing
uv run python scripts/basic_usage.py

# Advanced multi-channel workflows
uv run python scripts/multichannel_processing.py

# Zarr integration for large datasets  
uv run python scripts/zarr_integration.py
```

**Example Scripts:**
- **[`basic_usage.py`](scripts/basic_usage.py)** - Interface validation with CHW arrays
- **[`multichannel_processing.py`](scripts/multichannel_processing.py)** - Specialized channel processors
- **[`zarr_integration.py`](scripts/zarr_integration.py)** - Cloud-scale dataset handling

## ๐Ÿ—๏ธ Architecture

TileFlow processes images hierarchically for optimal memory usage:

```
Input Image โ†’ Grid Generation โ†’ Tile Processing โ†’ Reconstruction โ†’ Output
     โ†“              โ†“                โ†“               โ†“            โ†“
   16GB           Lazy            64MB          Overlap       16GB
                Iterator                       Handling
```

**Processing Modes:**
- **Direct Tiling**: Image โ†’ Tiles โ†’ Process โ†’ Reconstruct
- **Hierarchical**: Image โ†’ Chunks โ†’ Tiles โ†’ Process โ†’ Reconstruct

**Core Components:**
- **GridSpec**: Defines tiling strategy with intelligent overlap
- **TileFlow**: Main processor with configure/run interface  
- **Reconstruction**: Seamless merge with artifact elimination
- **Backends**: Support for numpy, zarr, and custom data sources

## ๐Ÿ› ๏ธ Development

```bash
# Clone and setup
git clone <repository>
cd TileFlow
uv sync

# Run tests
uv run pytest

# Code quality
uv run ruff check
uv run ruff format
uv run mypy src/tileflow

# Build package
uv build
```

## ๐Ÿงฌ Scientific Applications

**Fluorescence Microscopy:**
```python
# Multi-fluorophore analysis
channels = ["DAPI", "FITC", "TRITC", "Cy5"]
for i, name in enumerate(channels):
    channel_data = image_chw[i]
    processed = specialized_processor[name].process(channel_data)
    analyze_fluorophore_distribution(processed, name)
```

**Whole-Slide Pathology:**
```python
# Process gigapixel pathology slides
wsi_processor = TileFlow(
    tile_size=(512, 512), 
    overlap=(64, 64),
    chunk_size=(2048, 2048)  # Hierarchical processing
)
wsi_processor.configure(function=tissue_classifier)
classification_map = wsi_processor.run(whole_slide_image)
```

**Satellite Imagery:**
```python
# Multispectral satellite analysis
spectral_bands = ["red", "green", "blue", "nir", "swir1", "swir2"]
for band_idx, band_name in enumerate(spectral_bands):
    band_data = satellite_image[band_idx]
    vegetation_index = calculate_ndvi(band_data)
```

## ๐Ÿค Contributing

TileFlow is built for the scientific computing community. We welcome contributions for:

- **New Backends**: TIFF, HDF5, cloud storage adapters
- **Processing Algorithms**: Segmentation, enhancement, feature extraction
- **Performance**: GPU acceleration, distributed processing
- **Documentation**: Tutorials, use case examples

## ๐Ÿ“„ License

MIT License - see [LICENSE](LICENSE) file for details.

## ๐Ÿ™ Acknowledgments

**Valentin Poque** - Core development and architecture (July-September 2025)

---

<div align="center">

**Process any image, any size, any channel count.**  
*TileFlow scales with your data.*

[๐Ÿ“– Documentation](docs/) โ€ข [๐Ÿ› Issues](issues/) โ€ข [๐Ÿ’ฌ Discussions](discussions/)

</div>
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tileflow",
    "maintainer": "TileFlow Contributors",
    "docs_url": null,
    "requires_python": ">=3.13",
    "maintainer_email": null,
    "keywords": "computer-vision, deep-learning, image-processing, memory-efficient, scientific-computing, tiling",
    "author": "TileFlow Contributors",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/a8/56/3c09c9ca0ca8cae70e256bacb993f84172744fe5e9db6b42360ef7d9401c/tileflow-0.6.0.tar.gz",
    "platform": null,
    "description": "# TileFlow\n\n> **High-performance tile-based image processing for scientific computing**\n\nProcess gigapixel images with minimal memory footprint through intelligent tiling and reconstruction. Designed for microscopy, whole-slide imaging, and large-scale computer vision workflows.\n\n[![Python 3.13+](https://img.shields.io/badge/python-3.13+-blue.svg)](https://www.python.org/downloads/)\n[![NumPy](https://img.shields.io/badge/numpy-2.2.0+-orange.svg)](https://numpy.org/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)\n\n## \ud83d\ude80 Key Features\n\n- **\ud83e\udde0 Memory Efficient**: Process images larger than RAM using intelligent tiling\n- **\ud83d\udd2c Multi-Channel Ready**: Native CHW format support for microscopy workflows  \n- **\u26a1 Zero-Copy Views**: Leverages numpy slicing for maximum performance\n- **\ud83d\udd27 Seamless Reconstruction**: Intelligent overlap handling eliminates artifacts\n- **\u2601\ufe0f Cloud-Scale**: Built-in zarr integration for massive datasets\n- **\ud83c\udfaf Pluggable Pipeline**: Custom processing functions integrate seamlessly\n\n## \ud83d\udce6 Installation\n\n```bash\npip install tileflow\n```\n\n## \ud83d\udd25 Quick Start\n\n### Basic Image Processing\n\n```python\nfrom tileflow import TileFlow\nimport numpy as np\n\n# Define your processing function\ndef enhance_contrast(tile):\n    \"\"\"Enhance contrast using histogram stretching.\"\"\"\n    p2, p98 = np.percentile(tile, (2, 98))\n    return np.clip((tile - p2) / (p98 - p2 + 1e-8), 0, 1)\n\n# Configure and run processor\nprocessor = TileFlow(tile_size=(256, 256), overlap=(16, 16))\nprocessor.configure(function=enhance_contrast)\nresult = processor.run(large_image)\n```\n\n### Multi-Channel Microscopy\n\n```python\nfrom tileflow import generate_multichannel_image, SobelEdgeDetector\n\n# Generate realistic 8-channel microscopy data [C, H, W]\nimage_chw = generate_multichannel_image(shape=(8, 2048, 2048))\n\n# Process DAPI channel for nuclei detection\ndapi_channel = image_chw[0]  # Extract nuclei channel\nsobel = SobelEdgeDetector(tile_size=(256, 256), overlap=(16, 16))\nnuclei_edges = sobel.process(dapi_channel)\n\n# Apply different processing to each channel\nfor i, channel in enumerate(image_chw):\n    if i == 0:  # DAPI - nuclei segmentation\n        processed = sobel.process(channel)\n        nuclei_mask = processed > np.percentile(processed, 95)\n    else:  # Other channels - generic enhancement\n        processed = sobel.process(channel)\n    \n    print(f\"Channel {i}: {processed.max():.3f} max intensity\")\n```\n\n### Zarr for Massive Datasets\n\n```python\nimport zarr\nimport numpy as np\nfrom tileflow import TileFlow\n\n# Create zarr dataset for efficient storage\ndataset = zarr.open('microscopy.zarr', mode='w', \n                   shape=(16, 8192, 8192), chunks=(1, 1024, 1024))\n\n# Process channels individually to manage memory\nprocessor = TileFlow(tile_size=(512, 512), overlap=(32, 32))\nprocessor.configure(function=your_analysis_function)\n\nfor channel_idx in range(16):\n    # Load single channel from zarr (memory efficient)\n    channel_data = np.array(dataset[channel_idx])\n    \n    # Process with TileFlow\n    result = processor.run(channel_data)\n    \n    # Save or analyze result\n    print(f\"Channel {channel_idx} processed: {result.shape}\")\n```\n\n## \ud83e\uddea Advanced Examples\n\n### Custom Multi-Channel Pipeline\n\n```python\nclass NucleiSegmentationPipeline:\n    \"\"\"Specialized pipeline for DAPI nuclei segmentation.\"\"\"\n    \n    def __init__(self, sensitivity=0.95):\n        self.sensitivity = sensitivity\n        self.processor = TileFlow(tile_size=(256, 256), overlap=(16, 16))\n    \n    def segment_nuclei(self, tile):\n        \"\"\"Apply Sobel + thresholding for nuclei detection.\"\"\"\n        # Sobel edge detection\n        gx = np.gradient(tile, axis=1)\n        gy = np.gradient(tile, axis=0) \n        edges = np.sqrt(gx*gx + gy*gy)\n        \n        # Adaptive thresholding\n        threshold = np.percentile(edges, self.sensitivity * 100)\n        return (edges > threshold).astype(np.uint8)\n    \n    def process(self, dapi_channel):\n        \"\"\"Process DAPI channel for nuclei segmentation.\"\"\"\n        self.processor.configure(function=self.segment_nuclei)\n        return self.processor.run(dapi_channel)\n\n# Use the pipeline\npipeline = NucleiSegmentationPipeline(sensitivity=0.95)\nnuclei_mask = pipeline.process(image_chw[0])\nprint(f\"Detected {nuclei_mask.sum()} nuclei pixels\")\n```\n\n### Concurrent Multi-Channel Processing\n\n```python\nfrom concurrent.futures import ThreadPoolExecutor\nfrom tileflow import SobelEdgeDetector\n\ndef process_channel_pair(args):\n    \"\"\"Process a single channel with appropriate algorithm.\"\"\"\n    channel_idx, channel_data = args\n    \n    if channel_idx == 0:  # DAPI\n        processor = NucleiSegmentationPipeline()\n        return channel_idx, processor.process(channel_data)\n    else:  # Other channels\n        sobel = SobelEdgeDetector()\n        return channel_idx, sobel.process(channel_data)\n\n# Process multiple channels concurrently\nwith ThreadPoolExecutor(max_workers=4) as executor:\n    tasks = [(i, image_chw[i]) for i in range(8)]\n    futures = [executor.submit(process_channel_pair, task) for task in tasks]\n    \n    results = {}\n    for future in futures:\n        channel_idx, result = future.result()\n        results[channel_idx] = result\n        print(f\"\u2713 Channel {channel_idx} complete\")\n```\n\n## \ud83c\udfaf Use Cases\n\n| Domain | Application | Image Size | Channels |\n|--------|-------------|------------|----------|\n| \ud83d\udd2c **Microscopy** | Fluorescence imaging, pathology | 2K-16K | 4-32 |\n| \ud83e\udde0 **Deep Learning** | Model inference, preprocessing | 1K-8K | 1-3 |\n| \ud83d\udef0\ufe0f **Remote Sensing** | Satellite analysis, multispectral | 4K-32K | 8-256 |\n| \ud83d\udcf1 **Computer Vision** | Panoramic stitching, high-res analysis | 2K-16K | 1-4 |\n\n## \ud83d\udcca Performance Benchmarks\n\n| Dataset | Memory Usage | Processing Time | Zarr Compression |\n|---------|--------------|-----------------|------------------|\n| 2K \u00d7 2K \u00d7 8ch | 128 MB | 2.1s | 77% reduction |\n| 4K \u00d7 4K \u00d7 16ch | 256 MB | 8.4s | 75% reduction |\n| 8K \u00d7 8K \u00d7 32ch | 512 MB | 33.2s | 76% reduction |\n| 16K \u00d7 16K \u00d7 8ch | 1.2 GB | 45.6s | 78% reduction |\n\n*Consumer hardware (16GB RAM, 8-core CPU) with Sobel edge detection*\n\n## \ud83d\udd0d Enhanced Monitoring & Callbacks\n\nTileFlow provides a comprehensive callback system for monitoring processing performance, memory usage, and energy consumption:\n\n### Progress & Performance Tracking\n\n```python\nfrom tileflow import TileFlow, ProgressCallback, MetricsCallback\n\n# Basic progress tracking\nprocessor = TileFlow(tile_size=(256, 256), overlap=(32, 32))\nprocessor.configure(function=your_function)\n\nprogress = ProgressCallback(verbose=True, show_rate=True)\nmetrics = MetricsCallback(verbose=True)\n\nresult = processor.run(image, callbacks=[progress, metrics])\n```\n\n### Memory Usage Monitoring\n\n```python\nfrom tileflow import MemoryTracker\n\n# Track memory usage during processing\nmemory_tracker = MemoryTracker(detailed=True)\nresult = processor.run(large_image, callbacks=[memory_tracker])\n\n# Get detailed statistics\nmemory_stats = memory_tracker.get_memory_stats()\nprint(f\"Peak memory: {memory_stats['peak_delta_bytes'] / 1024**2:.1f} MB\")\n```\n\n### Energy Consumption Tracking\n\n```python\nfrom tileflow import CodeCarbonTracker\n\n# Track CO\u2082 emissions (requires: pip install codecarbon)\ncarbon_tracker = CodeCarbonTracker(\n    project_name=\"my-analysis\",\n    output_dir=\"./carbon_logs\"\n)\n\nresult = processor.run(image, callbacks=[carbon_tracker])\nemissions = carbon_tracker.get_emissions_data()\nprint(f\"CO\u2082 emissions: {emissions['emissions_kg']:.6f} kg\")\n```\n\n### Comprehensive Monitoring Suite\n\n```python\nfrom tileflow import CompositeCallback, ProgressCallback, MemoryTracker, CodeCarbonTracker\n\n# Combine multiple monitoring callbacks\nmonitoring_suite = CompositeCallback([\n    ProgressCallback(verbose=True),\n    MemoryTracker(detailed=False),\n    CodeCarbonTracker(project_name=\"scientific-analysis\")\n])\n\nresult = processor.run(image, callbacks=[monitoring_suite])\n```\n\n### Custom Scientific Callbacks\n\n```python\nfrom tileflow import TileFlowCallback\n\nclass ImageQualityCallback(TileFlowCallback):\n    \"\"\"Custom callback for scientific image analysis.\"\"\"\n    \n    def on_tile_end(self, tile, tile_index, total_tiles):\n        # Analyze each processed tile\n        data = tile.image_data[0]\n        snr = np.mean(data) / np.std(data)\n        self.quality_metrics.append(snr)\n    \n    def on_processing_end(self, stats):\n        print(f\"Average SNR: {np.mean(self.quality_metrics):.2f}\")\n\nprocessor.run(image, callbacks=[ImageQualityCallback()])\n```\n\n## \ud83d\udcda Complete Examples\n\nRun comprehensive examples from the `scripts/` directory:\n\n```bash\n# Basic CHW format processing\nuv run python scripts/basic_usage.py\n\n# Advanced multi-channel workflows\nuv run python scripts/multichannel_processing.py\n\n# Zarr integration for large datasets  \nuv run python scripts/zarr_integration.py\n```\n\n**Example Scripts:**\n- **[`basic_usage.py`](scripts/basic_usage.py)** - Interface validation with CHW arrays\n- **[`multichannel_processing.py`](scripts/multichannel_processing.py)** - Specialized channel processors\n- **[`zarr_integration.py`](scripts/zarr_integration.py)** - Cloud-scale dataset handling\n\n## \ud83c\udfd7\ufe0f Architecture\n\nTileFlow processes images hierarchically for optimal memory usage:\n\n```\nInput Image \u2192 Grid Generation \u2192 Tile Processing \u2192 Reconstruction \u2192 Output\n     \u2193              \u2193                \u2193               \u2193            \u2193\n   16GB           Lazy            64MB          Overlap       16GB\n                Iterator                       Handling\n```\n\n**Processing Modes:**\n- **Direct Tiling**: Image \u2192 Tiles \u2192 Process \u2192 Reconstruct\n- **Hierarchical**: Image \u2192 Chunks \u2192 Tiles \u2192 Process \u2192 Reconstruct\n\n**Core Components:**\n- **GridSpec**: Defines tiling strategy with intelligent overlap\n- **TileFlow**: Main processor with configure/run interface  \n- **Reconstruction**: Seamless merge with artifact elimination\n- **Backends**: Support for numpy, zarr, and custom data sources\n\n## \ud83d\udee0\ufe0f Development\n\n```bash\n# Clone and setup\ngit clone <repository>\ncd TileFlow\nuv sync\n\n# Run tests\nuv run pytest\n\n# Code quality\nuv run ruff check\nuv run ruff format\nuv run mypy src/tileflow\n\n# Build package\nuv build\n```\n\n## \ud83e\uddec Scientific Applications\n\n**Fluorescence Microscopy:**\n```python\n# Multi-fluorophore analysis\nchannels = [\"DAPI\", \"FITC\", \"TRITC\", \"Cy5\"]\nfor i, name in enumerate(channels):\n    channel_data = image_chw[i]\n    processed = specialized_processor[name].process(channel_data)\n    analyze_fluorophore_distribution(processed, name)\n```\n\n**Whole-Slide Pathology:**\n```python\n# Process gigapixel pathology slides\nwsi_processor = TileFlow(\n    tile_size=(512, 512), \n    overlap=(64, 64),\n    chunk_size=(2048, 2048)  # Hierarchical processing\n)\nwsi_processor.configure(function=tissue_classifier)\nclassification_map = wsi_processor.run(whole_slide_image)\n```\n\n**Satellite Imagery:**\n```python\n# Multispectral satellite analysis\nspectral_bands = [\"red\", \"green\", \"blue\", \"nir\", \"swir1\", \"swir2\"]\nfor band_idx, band_name in enumerate(spectral_bands):\n    band_data = satellite_image[band_idx]\n    vegetation_index = calculate_ndvi(band_data)\n```\n\n## \ud83e\udd1d Contributing\n\nTileFlow is built for the scientific computing community. We welcome contributions for:\n\n- **New Backends**: TIFF, HDF5, cloud storage adapters\n- **Processing Algorithms**: Segmentation, enhancement, feature extraction\n- **Performance**: GPU acceleration, distributed processing\n- **Documentation**: Tutorials, use case examples\n\n## \ud83d\udcc4 License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n## \ud83d\ude4f Acknowledgments\n\n**Valentin Poque** - Core development and architecture (July-September 2025)\n\n---\n\n<div align=\"center\">\n\n**Process any image, any size, any channel count.**  \n*TileFlow scales with your data.*\n\n[\ud83d\udcd6 Documentation](docs/) \u2022 [\ud83d\udc1b Issues](issues/) \u2022 [\ud83d\udcac Discussions](discussions/)\n\n</div>",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2025 Mantalys France, SAS  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Fast, memory-efficient image tiling and reconstruction for deep learning and scientific computing",
    "version": "0.6.0",
    "project_urls": {
        "Homepage": "https://github.com/mantalys/tileflow",
        "Repository": "https://github.com/mantalys/tileflow.git"
    },
    "split_keywords": [
        "computer-vision",
        " deep-learning",
        " image-processing",
        " memory-efficient",
        " scientific-computing",
        " tiling"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6b60ef910da925cd0f791661b3df96e68a5b50037d86ff519cc5af37d1dc6549",
                "md5": "0af56dc3bd738764e5971f17b376a7ee",
                "sha256": "9a2a85c7baa312b6ad695e82efd83114c58a341245c11cc1a0710b8de5b55213"
            },
            "downloads": -1,
            "filename": "tileflow-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0af56dc3bd738764e5971f17b376a7ee",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.13",
            "size": 26831,
            "upload_time": "2025-08-15T16:11:30",
            "upload_time_iso_8601": "2025-08-15T16:11:30.940630Z",
            "url": "https://files.pythonhosted.org/packages/6b/60/ef910da925cd0f791661b3df96e68a5b50037d86ff519cc5af37d1dc6549/tileflow-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a8563c09c9ca0ca8cae70e256bacb993f84172744fe5e9db6b42360ef7d9401c",
                "md5": "7b27272341e7ca5943f4f51a3d52b60e",
                "sha256": "3e796e67a445e2f598f40e2a8f10e673d595fd5b44bfebf3b0b9480f4403e438"
            },
            "downloads": -1,
            "filename": "tileflow-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7b27272341e7ca5943f4f51a3d52b60e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.13",
            "size": 25628,
            "upload_time": "2025-08-15T16:11:32",
            "upload_time_iso_8601": "2025-08-15T16:11:32.115287Z",
            "url": "https://files.pythonhosted.org/packages/a8/56/3c09c9ca0ca8cae70e256bacb993f84172744fe5e9db6b42360ef7d9401c/tileflow-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-15 16:11:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mantalys",
    "github_project": "tileflow",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tileflow"
}
        
Elapsed time: 1.29303s