Skip to content
Back to skills

Spectral Index Segmentation

ASecurity

Compute normalized spectral band ratios (NDWI, CCCI, NDVI) from multispectral imagery and threshold for binary segmentation of water, vegetation, or other targets

  • 61 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 12, 2026
developmentpython

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill spectral-index-segmentation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Spectral Index Segmentation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Spectral Index Segmentation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-spectral-index-segmentation/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-spectral-index-segmentation)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cv-spectral-index-segmentation
description: Compute normalized spectral band ratios (NDWI, CCCI, NDVI) from multispectral imagery and threshold for binary segmentation of water, vegetation, or other targets
---

# Spectral Index Segmentation

## Overview

Multispectral satellites capture bands beyond visible RGB (NIR, red-edge, SWIR). Normalized difference indices combine these bands into single-channel images where target features (water, vegetation, chlorophyll) have distinct value ranges. A simple threshold on the index produces a binary segmentation mask without any ML model.

## Quick Start

```python
import numpy as np
from skimage.transform import resize

def ndwi(green, nir):
    return (green - nir) / (green + nir + 1e-10)

def ccci(red, red_edge, mir):
    return ((mir - red_edge) / (mir + red_edge + 1e-10) *
            (mir - red) / (mir + red + 1e-10))

def ndvi(red, nir):
    return (nir - red) / (nir + red + 1e-10)

ms = load_16band_image(image_id)
re = resize(ms[5], rgb.shape[:2])
mir = resize(ms[7], rgb.shape[:2])
r = rgb[:, :, 0].astype(float)

index = ccci(r, re, mir)
water_mask = (index > 0.11).astype(np.uint8)
```

## Workflow

1. Load multispectral bands and resize to a common spatial resolution
2. Select bands for the target index (e.g., green+NIR for NDWI)
3. Compute the normalized ratio — values typically range [-1, 1]
4. Threshold to produce a binary mask
5. Optionally apply morphological cleaning (opening/closing)

## Key Decisions

- **Index choice**: NDWI for water, NDVI for vegetation, CCCI for chlorophyll/waterways
- **Threshold tuning**: varies by sensor, scene, and season — tune on labeled samples
- **Band alignment**: always resize lower-res bands to match before computing indices
- **vs ML models**: spectral indices are interpretable baselines; often competitive for simple targets

## References

- [Waterway 0.095 LB](https://www.kaggle.com/code/resolut/waterway-0-095-lb)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.