developmentseed / developmentseed/titiler-cmr
Add custom algorithm for SWIR contrast stretch
- Dominant language
- Python
- Stars
- 25
- Forks
- 9
- Avg merge
- 1d 6m
- Merged PRs (30d)
- 1
Description
In the eoapi implementation for FIRMS we included a custom post processing function for contrast stretch for the swir band combination.
```
def swir(data, mask) -> Tuple[numpy.ndarray, numpy.ndarray]:
low_value = math.e
high_value = 255
low_threshold = math.log(1000)
high_threshold = math.log(7500)
data = numpy.log(data)
data[numpy.where(data <= low_threshold)] = low_value
data[numpy.where(data >= high_threshold)] = high_value
indices = numpy.where(
(data > low_value) & (data < high_value)
)
data[indices] = (
high_value * (data[indices] - low_threshold) / (high_threshold - low_threshold)
)
return data.astype("uint8"), mask
```
This predates the inclusion of the `BaseAlgorithm` base class and should now be included as [custom algorithm](https://developmentseed.org/titiler/advanced/Algorithms/#create-your-own-algorithm) so it can be discovered via the `algorithms` endpoint.
Contributor guide
Assessment
This issue has not been assessed yet.