developmentseed / developmentseed/titiler-cmr

Add custom algorithm for SWIR contrast stretch

Open
#46 0 comments 0 reactions 1 assignee Claimed by @sharkinsspatial View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.