# tonzowonzo/sar_utils architecture

> Architecture diagram of the GitHub repository tonzowonzo/sar_utils, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tonzowonzo/sar_utils
- Repository: https://github.com/tonzowonzo/sar_utils

## Overview

a. Primary Data Flow:
- Raw SAR Image → Preprocessing → Model Selection → Despeckling → Output Image

b. Training Flow:
- Data Generator → Synthetic Speckle Creation → Model Training → Model Storage

##### Key Technical Elements to Highlight

a. Model Architecture Section:
- Dilation-based CNN
- Hybrid approach combining Wang and Zhang methods
- Optional skip connections for residual learning

b. Processing Components:
- Image scaling operations
- Linear/Log transformation handling
- Backscatter coefficient processing

##### Specific Implementation Details

- Input image requirements (0-255 scale)
- Processing time indicators (30s for 6000x6000 image)
- GPU/CUDA acceleration support
- Model selection logic

##### Additional Elements

a. Configuration Parameters:
- Image scaling thresholds
- Backscatter limits (0.2 threshold)
- Resolution handling

b. Performance Metrics:
- Processing time
- Model comparison results

##### Integration Points

- Interface with external libraries
- GPU acceleration points
- Potential expansion points for future implementations

Key Considerations:

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        style Legend fill:#f5f5f5,stroke:#333
        L1[Input/Output]:::io
        L2[Processing Module]:::process
        L3[Model Component]:::model
        L4[Training Component]:::training
        L5[(Storage)]:::storage
    end

    subgraph "Input Layer"
        RawSAR[Raw SAR Images]:::io
        ImgFormat[Image Format Handler]:::io
    end

    subgraph "Processing Pipeline"
        SARProc[SAR Processing Module]:::process
        Despeckle[Despeckling Module]:::process
        DataGen[Data Generation Module]:::process
    end

    subgraph "Model Components"
        ModelArch[Model Architecture]:::model
        ModelTrain[Model Training]:::model
        subgraph "Trained Models"
            Model1[Dilation CNN]:::model
            Model2[Wang Method]:::model
            Model3[Zhang Method]:::model
        end
    end

    subgraph "Storage"
        ModelStorage[(Trained Models Storage)]:::storage
        InputEx[(Input Examples)]:::storage
        OutputEx[(Output Examples)]:::storage
    end

    subgraph "Output Layer"
        ProcessedImg[Despeckled SAR Image]:::io
        ImgAnalysis[Image Analysis Tools]:::process
    end

    RawSAR --> ImgFormat
    ImgFormat --> SARProc
    SARProc --> Despeckle
    DataGen --> ModelTrain
    ModelArch --> ModelTrain
    ModelTrain --> ModelStorage
    ModelStorage --> Model1
    ModelStorage --> Model2
    ModelStorage --> Model3
    Model1 --> Despeckle
    Model2 --> Despeckle
    Model3 --> Despeckle
    Despeckle --> ProcessedImg
    ProcessedImg --> ImgAnalysis

    classDef io fill:#b3e0ff,stroke:#333
    classDef process fill:#98FB98,stroke:#333
    classDef model fill:#FFA07A,stroke:#333
    classDef training fill:#DDA0DD,stroke:#333
    classDef storage fill:#F0E68C,stroke:#333

    click SARProc "https://github.com/tonzowonzo/SAR_utils/blob/main/sar_processing/preprocess_sar_images.py"
    click DataGen "https://github.com/tonzowonzo/SAR_utils/blob/main/sar_despeckling/data_generator.py"
    click ModelArch "https://github.com/tonzowonzo/SAR_utils/blob/main/sar_despeckling/model.py"
    click ModelTrain "https://github.com/tonzowonzo/SAR_utils/blob/main/sar_despeckling/model_train.py"
    click Despeckle "https://github.com/tonzowonzo/SAR_utils/blob/main/sar_despeckling/despeckle_sar_image.py"
    click ModelStorage "https://github.com/tonzowonzo/SAR_utils/tree/main/trained_models/"
    click InputEx "https://github.com/tonzowonzo/SAR_utils/tree/main/examples/capella/speckled/"
    click OutputEx "https://github.com/tonzowonzo/SAR_utils/tree/main/examples/capella/despeckled/"
    click ImgAnalysis "https://github.com/tonzowonzo/SAR_utils/blob/main/sar_despeckling/model_look_at_images.py"
    click SARProc "https://github.com/tonzowonzo/SAR_utils/blob/main/sar_processing/prepare_sar_imagery.py"
```
