Skip to content

feat: Add NDWI visualization tool for label quality inspection#86

Open
AnvayKharb wants to merge 2 commits intofwitmer:masterfrom
AnvayKharb:feature/ndwi-visualization-tool
Open

feat: Add NDWI visualization tool for label quality inspection#86
AnvayKharb wants to merge 2 commits intofwitmer:masterfrom
AnvayKharb:feature/ndwi-visualization-tool

Conversation

@AnvayKharb
Copy link
Copy Markdown

Adds visualize_ndwi.py to visually inspect NDWI label quality
before training.

What it does

  • 4-panel output: Original RGB | NDWI Heatmap | Binary Mask | Overlay
  • Prints NDWI stats (min, max, mean, water/land ratio)
  • Supports single image and directory input
  • Window size configurable via CLI or config.json

Usage

python visualize_ndwi.py sample_data/PlanetLabs/
python visualize_ndwi.py sample_data/PlanetLabs/ --window_size 128

Notes

image image image image

- Add visualize_ndwi.py: generates 4-panel NDWI label quality visualization
  (Original RGB | NDWI Heatmap | Binary Mask | Overlay)
- Supports single image and batch directory processing via CLI
- Implements simplified sliding-window Otsu thresholding for quick inspection
- Band order matches existing codebase (Green=band2, NIR=last band)
- Gaussian blur params match ndwi_labels.py defaults (kernel 9x9, sigma 6)
- Majority threshold matches ndwi_labels.py (0.55)
- Add 'ndwi' config block to config_template.json with window_size,
  blur_kernel, blur_sigma, and majority_threshold parameters
- CLI args (--window_size, --blur_kernel, --blur_sigma) override config values
- Graceful fallback when ndwi config block is absent
- Band count validation prevents crashes on non-multispectral images
- Filters out UDM files in directory mode
- No modifications to existing pipeline scripts
- Raise std threshold from 1e-3 to 10 to reject single-class windows
  that caused Otsu to split land texture noise as water
- Correct uint8 conversion to (ndwi * 127) + 128 matching ndwi_labels.py
- Add global mean-threshold fallback for uncovered pixels, matching
  the concatenation logic in ndwi_labels.py (mean + 10 offset)
- Result: clean solid land (black) and water (white) regions
@Ritika-K7
Copy link
Copy Markdown
Contributor

@AnvayKharb
Thanks for working on this.
The visualization script is useful for checking the NDWI output and label quality before training. It is also helpful while exploring and testing the dataset. Please continue experimenting with the dataset and the pipeline. It would be especially interesting to see further experiments that could help improve the coastline extraction or reduce misclassification issues.

Looking forward to seeing more of your experiments and findings.

@AnvayKharb
Copy link
Copy Markdown
Author

Thank you @Ritika-K7 I will continue experimenting with the dataset and pipeline and share my findings here. I have also sent an email regarding my GSoC proposal plan please do check it whenever you've time .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants