-
-
Notifications
You must be signed in to change notification settings - Fork 64
Description
It could be nice to implement two Protocols for our Filter classes in the filters subpackage, namely ImageFilter and MorphologicalFilter.
This would be very similar to the implementation of a Scorer protocol (see https://github.com/histolab/histolab/blob/master/src/histolab/scorer.py#L36-L44)
The idea would be to have an abstract and not implemented __call__ method and a concrete __repr__ method, since every filter share the same __repr__ implementation:
def __repr__(self) -> str:
return self.__class__.__name__ + "()"Careful attention must be paid in the type annotations for the __call__ method for the two protocols:
- image filters take a
PIL.Image.Imageand outputUnion[PIL.Image.Image, np.ndarray] - morphological filters take a
np.ndarrayand output anp.ndarray
Once we have the protocols, all the classes must subclass the respective protocol to get the implementation of __repr__, and we can use the protocols to improve the type annotations of apply_filters method of Tile (see https://github.com/histolab/histolab/blob/master/src/histolab/tile.py#L50)