Metadata-Version: 2.4
Name: zsplit
Version: 1.0.0
Summary: Z-Split Normalization: Zero-Preserving Split Normalization for bipolar spectral indices
Author-email: Abdulrhman Almoadi <aalmoadi@kacst.edu.sa>
License: MIT License
        
        Copyright (c) 2026 Abdulrhman Almoadi
        
        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.
        
Project-URL: Homepage, https://github.com/aalmoadi/endwi
Project-URL: Repository, https://github.com/aalmoadi/endwi
Project-URL: Documentation, https://github.com/aalmoadi/endwi/tree/main/Z-Split_Normalization
Project-URL: Bug Tracker, https://github.com/aalmoadi/endwi/issues
Project-URL: DOI, https://doi.org/10.5281/zenodo.20602710
Project-URL: Paper, https://doi.org/10.5194/egusphere-2026-672
Keywords: normalization,remote-sensing,flood-detection,spectral-index,ENDWI,NDWI,bipolar,zero-preserving,Otsu,GIS,GeoAI,machine-learning,deep-learning,SAR,Sentinel-2
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: Topic :: Scientific/Engineering :: Image Processing
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.20
Provides-Extra: raster
Requires-Dist: rasterio>=1.2; extra == "raster"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: rasterio>=1.2; extra == "dev"
Requires-Dist: matplotlib; extra == "dev"
Dynamic: license-file

# zsplit — Zero-Preserving Split Normalization

[![PyPI version](https://badge.fury.io/py/zsplit.svg)](https://pypi.org/project/zsplit/)
[![DOI](https://zenodo.org/badge/1037018439.svg)](https://doi.org/10.5281/zenodo.20602709)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A normalization technique for **bipolar spectral indices** where **zero carries physical meaning as a class boundary** (e.g., water vs. non-water in flood detection).

## Installation

```bash
pip install zsplit
```

With raster support:

```bash
pip install zsplit[raster]
```

## Quick Start

```python
import numpy as np
from zsplit import normalize

# Simulated raw ENDWI values (DN scale — extremely narrow range)
arr = np.array([-0.00041, -0.00020, 0.0, 0.00008, 0.00015])

result = normalize(arr)
print(result)
# [-1.     -0.488   0.      0.533   1.   ]
```

## Raster Support

```python
from zsplit import normalize_raster

normalize_raster('ENDWI_raw.tif', 'ENDWI_zsplit.tif')
```

## Formula

```
         ⎧  x / max(X⁺)    if x > 0   →  [0,  1]
Z(x)  =  ⎨  0               if x = 0   →  0 (preserved)
         ⎩  x / |min(X⁻)|  if x < 0   →  [-1, 0]
```

## Why Z-Split?

| Property | Min-Max | Z-Score | **Z-Split** |
|---|---|---|---|
| Preserves zero as class boundary | ❌ | ❌ | ✅ |
| Stable on narrow near-zero ranges | ❌ | ⚠️ | ✅ |
| Suitable for Otsu thresholding | ❌ | ⚠️ | ✅ |
| Handles skewed distributions | ❌ | ⚠️ | ✅ |
| Multi-temporal direction preserved | ❌ | ❌ | ✅ |
| Output range | [0, 1] | Unbounded | **[−1, 1]** |

## Citation

```bibtex
@article{almoadi2026endwi,
  author  = {Almoadi, Abdulrhman},
  title   = {Reducing False Alarms in Urban Flood Detection: An Enhanced NDWI (ENDWI)
             with Hybrid Max Fusion on Sentinel-2 Data},
  journal = {EGUsphere [preprint]},
  year    = {2026},
  doi     = {10.5194/egusphere-2026-672}
}
```

## License

MIT License
