Skip to content

Commit

Permalink
Merge branch 'hotfix/v2.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
tayden committed Oct 19, 2020
2 parents 668f175 + cb257d4 commit bfd4699
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
22 changes: 17 additions & 5 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def process(self, masker: Masker):
return masker.process(max_workers=self.max_workers, callback=lambda _: progress.update(),
err_callback=self._err_callback)

def rgb(self, img_dir: str, out_dir: str, thresholds: List[float] = (1, 1, 0.875), pixel_buffer: int = 0) -> None:
def rgb_threshold(self, img_dir: str, out_dir: str, thresholds: List[float] = (1, 1, 0.875),
pixel_buffer: int = 0) -> None:
"""Generate masks for glint regions in RGB imagery using Tom Bell's binning algorithm.
Parameters
Expand All @@ -58,8 +59,8 @@ def rgb(self, img_dir: str, out_dir: str, thresholds: List[float] = (1, 1, 0.875
"""
self.process(RGBThresholdMasker(img_dir, out_dir, thresholds, pixel_buffer))

def dji_p4ms(self, img_dir: str, out_dir: str, thresholds: List[float] = (0.875, 1, 1, 1, 1),
pixel_buffer: int = 0) -> None:
def p4ms_threshold(self, img_dir: str, out_dir: str, thresholds: List[float] = (0.875, 1, 1, 1, 1),
pixel_buffer: int = 0) -> None:
"""Generate masks for glint regions in multispectral imagery from the DJI camera using Tom Bell's algorithm on
the Blue image band.
Expand All @@ -83,8 +84,8 @@ def dji_p4ms(self, img_dir: str, out_dir: str, thresholds: List[float] = (0.875,
"""
self.process(P4MSThresholdMasker(img_dir, out_dir, thresholds, pixel_buffer))

def micasense_rededge(self, img_dir: str, out_dir: str, thresholds: List[float] = (0.875, 1, 1, 1, 1),
pixel_buffer: int = 0) -> None:
def micasense_threshold(self, img_dir: str, out_dir: str, thresholds: List[float] = (0.875, 1, 1, 1, 1),
pixel_buffer: int = 0) -> None:
"""Generate masks for glint regions in multispectral imagery from the Micasense camera using Tom Bell's
algorithm on the blue image band.
Expand Down Expand Up @@ -139,3 +140,14 @@ def rgb_ratio(self, img_dir: str, out_dir: str, percent_diffuse: float = 0.95, t

if __name__ == '__main__':
fire.Fire(CLI)

# masker = MicasenseRedEdgeThresholdMasker("/media/taylor/Samsung_T5/Datasets/ExampleImages/MicasenseRededge", "/tmp",
# thresholds=(0.7, 0.7, 0.7, 0.7, 0.7))
# masker.process(callback=lambda paths: print(paths))
#
# masker = P4MSThresholdMasker("/media/taylor/Samsung_T5/Datasets/ExampleImages/P4MS", "/tmp",
# thresholds=(0.7, 0.7, 0.7, 0.7, 0.7))
# masker.process(callback=lambda paths: print(paths))
#
# masker = RGBThresholdMasker("/media/taylor/Samsung_T5/Datasets/ExampleImages/RGB", "/tmp")
# masker.process(callback=lambda paths: print(paths))
6 changes: 6 additions & 0 deletions core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
Date: 2020-09-18
Description:
"""

from .maskers import Masker, MicasenseRedEdgeIntensityRatioMasker, MicasenseRedEdgeThresholdMasker, \
P4MSIntensityRatioMasker, P4MSThresholdMasker, RGBIntensityRatioMasker, RGBThresholdMasker

__all__ = ["Masker", "RGBThresholdMasker", "P4MSThresholdMasker", "MicasenseRedEdgeThresholdMasker",
"RGBIntensityRatioMasker", "P4MSIntensityRatioMasker", "MicasenseRedEdgeIntensityRatioMasker"]
2 changes: 1 addition & 1 deletion core/image_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import numpy as np
from PIL import Image

from core.utils import list_images, normalize_img
from .utils import list_images, normalize_img

Image.MAX_IMAGE_PIXELS = None

Expand Down
17 changes: 2 additions & 15 deletions core/maskers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from PIL import Image
from scipy.ndimage import convolve

from core.glint_algorithms import GlintAlgorithm, IntensityRatioAlgorithm, ThresholdAlgorithm
from core.image_loaders import ImageLoader, MicasenseRedEdgeLoader, P4MSLoader, RGB8BitLoader
from .glint_algorithms import GlintAlgorithm, IntensityRatioAlgorithm, ThresholdAlgorithm
from .image_loaders import ImageLoader, MicasenseRedEdgeLoader, P4MSLoader, RGB8BitLoader


class Masker(object):
Expand Down Expand Up @@ -199,16 +199,3 @@ def __init__(self, img_dir: str, mask_dir: str,
super().__init__(algorithm=IntensityRatioAlgorithm(percent_diffuse, threshold),
image_loader=MicasenseRedEdgeLoader(img_dir, mask_dir),
pixel_buffer=pixel_buffer)


if __name__ == '__main__':
masker = MicasenseRedEdgeThresholdMasker("/media/taylor/Samsung_T5/Datasets/ExampleImages/MicasenseRededge", "/tmp",
thresholds=(0.7, 0.7, 0.7, 0.7, 0.7))
masker.process(callback=lambda paths: print(paths))

masker = P4MSThresholdMasker("/media/taylor/Samsung_T5/Datasets/ExampleImages/P4MS", "/tmp",
thresholds=(0.7, 0.7, 0.7, 0.7, 0.7))
masker.process(callback=lambda paths: print(paths))

masker = RGBThresholdMasker("/media/taylor/Samsung_T5/Datasets/ExampleImages/RGB", "/tmp")
masker.process(callback=lambda paths: print(paths))

0 comments on commit bfd4699

Please sign in to comment.