Skip to content

Commit

Permalink
mask results
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Feb 14, 2024
1 parent 79d70be commit 7af5b03
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 12 deletions.
5 changes: 3 additions & 2 deletions titiler/src/app/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import List, Callable

import cv2
import numpy as np

from titiler.core.algorithm import BaseAlgorithm
from rio_tiler.models import ImageData
Expand Down Expand Up @@ -62,10 +63,10 @@ def __call__(self, img: ImageData) -> ImageData:
data = cv2.normalize(src=data, dst=None, alpha=0, beta=2**8, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8U)
clahe = cv2.createCLAHE(clipLimit=1, tileGridSize=(3, 3))
eq_img = clahe.apply(data)
bounds = windows.bounds(windows.Window(self.tilesize, self.tilesize, self.tilesize, self.tilesize), img.transform)
pos_start, pos_end = self.buffer, self.buffer+self.tilesize
masked_data = np.ma.MaskedArray(eq_img[pos_start:pos_end, pos_start:pos_end], mask=img.mask)
return ImageData(
eq_img[pos_start:pos_end, pos_start:pos_end],
masked_data,
assets=img.assets,
crs=img.crs,
bounds=img.bounds,
Expand Down
66 changes: 56 additions & 10 deletions titiler/src/notebook.ipynb

Large diffs are not rendered by default.

0 comments on commit 7af5b03

Please sign in to comment.