# Processing Pipeline

Chloros 1.1.0 uses a 4-thread processing pipeline that operates as a staged assembly line. Each thread handles a distinct phase of the processing workflow, allowing multiple images to be processed concurrently at different stages.

***

## Pipeline Architecture

```
Images In → [Thread 1: Detection] → [Thread 2: Calibration] → [Thread 3: Processing] → [Thread 4: Export] → Files Out
```

Each image flows through all four threads in order. With Chloros+ multi-threaded processing, multiple images can be in different threads simultaneously — while Thread 3 processes one image, Thread 1 can be detecting the next, Thread 2 can be calibrating another, and Thread 4 can be writing a previously processed image to disk.

***

## Thread Details

### Thread 1: Detection

**Purpose**: Load images and detect calibration targets.

* Reads image files from disk (RAW, JPG)
* Extracts EXIF metadata (GPS, camera model, timestamps, exposure)
* Detects ArUco calibration targets in marked target images
* Outputs: image data + metadata + target detection results

This is primarily an I/O and CPU-bound thread.

### Thread 2: Calibration

**Purpose**: Compute calibration parameters from detected targets.

* Calculates reflectance calibration coefficients from target images
* Computes vignette correction parameters
* Determines per-band calibration curves
* Outputs: calibration parameters for each image

This is a CPU-bound computation thread.

### Thread 3: Processing (GPU)

**Purpose**: Apply corrections and calculate vegetation indices. **This is the most compute-intensive thread.**

* **Debayering**: Converts RAW Bayer pattern data to multi-channel images
  * Standard (Fast, Medium Quality) — default
  * Texture Aware (Slow, Highest Quality) — Chloros+ only, uses AI/ML denoising
* **Vignette correction**: Applies lens vignette correction across the image
* **Reflectance calibration**: Applies calibration coefficients to convert to reflectance values
* **Index calculation**: Computes vegetation indices (NDVI, NDRE, GNDVI, etc.)
* Outputs: processed image data ready for export

This thread benefits most from GPU acceleration. The [Dynamic Compute Adaptation](/chloros/processing-architecture/dynamic-compute-adaptation.md) system primarily optimizes this thread's behavior.

### Thread 4: Export

**Purpose**: Write processed images to disk.

* Writes output files in the selected format (TIFF 16-bit, TIFF 32-bit %, PNG, JPG)
* Embeds EXIF metadata in output files (GPS, timestamps, processing parameters)
* Organizes output into camera-model subfolders
* Outputs: final files on disk

This is primarily an I/O-bound thread. SSD storage significantly improves Thread 4 performance.

***

## Sequential vs. Pipelined Processing

### Free Mode (Sequential)

In the free version of Chloros, images are processed **one at a time**, sequentially through all four stages:

```
Image 1: [Detect] → [Calibrate] → [Process] → [Export]
                                                         Image 2: [Detect] → [Calibrate] → [Process] → [Export]
```

The GUI progress bar shows 2 stages: Target Detect and Processing.

### Chloros+ Mode (Pipelined)

With a Chloros+ license, all four threads operate **concurrently** on different images:

```
Thread 1: [Image 1] [Image 2] [Image 3] [Image 4] ...
Thread 2:           [Image 1] [Image 2] [Image 3] ...
Thread 3:                     [Image 1] [Image 2] ...
Thread 4:                               [Image 1] ...
```

The GUI progress bar shows 4 stages: Detecting, Analyzing, Calibrating, Exporting. Hover over the progress bar to see per-thread progress.

{% hint style="success" %}
**Pipelined processing with Chloros+** can be 3-5x faster than sequential processing, depending on your hardware and dataset size. The speedup is greatest on systems with fast GPUs and SSDs.
{% endhint %}

***

## Thread 4 Export Progress

In Chloros 1.1.0, the export thread (Thread 4) has its own dedicated progress tracking. You can monitor export progress separately:

**CLI:**

```bash
chloros-cli export-status
```

**SDK:**

```python
status = chloros.get_status()
print(f"Export: {status['export']['percent']}% - Phase: {status['export']['phase']}")
```

Processing is complete when Thread 4 reaches 100%.

***

## Relationship to Dynamic Compute Adaptation

The [Dynamic Compute Adaptation](/chloros/processing-architecture/dynamic-compute-adaptation.md) system primarily affects **Thread 3 (Processing)**:

* **`GPU_PARALLEL`** strategy: Thread 3 runs multiple images through the GPU simultaneously using the `fused_gpu` pipeline
* **`GPU_SINGLE`** strategy: Thread 3 processes one image at a time using the memory-efficient `tiled_gpu` pipeline
* **`CPU_PARALLEL`** strategy: Thread 3 uses CPU-based processing with multi-threaded parallelism

Thread 3's GPU memory allocation also changes dynamically as Threads 1 and 2 complete — see [Dynamic GPU Memory Allocation](/chloros/processing-architecture/dynamic-compute-adaptation.md#dynamic-gpu-memory-allocation).

***

## Next Steps

* [Dynamic Compute Adaptation](/chloros/processing-architecture/dynamic-compute-adaptation.md) — How Chloros selects the optimal strategy for your hardware
* [NVIDIA Jetson Guide](/chloros/linux-and-edge-computing/nvidia-jetson-guide.md) — Platform-specific pipeline behavior on Jetson
* [Monitoring the Processing](/chloros/processing-images-gui/monitoring-the-processing.md) — GUI progress monitoring


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mapir.gitbook.io/chloros/processing-architecture/processing-pipeline.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
