now the _remove_particles method is complete

added an average filter so that it is now equivalent to the matlab code it's based on.
This commit is contained in:
Guillaume Raffy 2019-09-18 12:06:18 +02:00
parent 1fd2fc4281
commit d973c0e1cd
3 changed files with 15 additions and 1 deletions

View File

@ -61,6 +61,13 @@ class IImageEngine(ABC):
:rtype IImage:
"""
@abc.abstractmethod
def mean_filter(self, image, radius):
"""Each pixel becomes an average of its neighbours within the given radius
:param IImage image:
:param int radius: in pixels
"""
@abc.abstractmethod
def perform_gray_morphology(self, image, operator, structuring_element_shape, structuring_element_radius):

View File

@ -144,6 +144,10 @@ class IJImageEngine(IImageEngine):
print('max_image', max_image)
return IJImage(self, max_image)
def mean_filter(self, image, radius):
"""Implement interface method."""
IJ.run(image.ij_image, "Mean...", "radius=%d" % radius)
def perform_gray_morphology(self, image, operator, structuring_element_shape, structuring_element_radius):
"""
:param IJImage image:
@ -154,8 +158,8 @@ class IJImageEngine(IImageEngine):
# we use opencv version because imagej's slow version is way too slow for big values of structuring_element_radius
perform_gray_morphology_with_ijopencv(image, operator, structuring_element_shape, structuring_element_radius)
def replace_border(self, image, band_width):
"""Implement interface method."""
raise NotImplementedError()
return image

View File

@ -20,6 +20,9 @@ class WhiteEstimator(object):
IImageEngine.get_instance().perform_gray_morphology(white_estimate, operator='open', structuring_element_shape='square', structuring_element_radius=(self.open_size + 1) / 2)
IImageEngine.get_instance().perform_gray_morphology(white_estimate, operator='close', structuring_element_shape='square', structuring_element_radius=(self.close_size + 1) / 2)
IImageEngine.get_instance().mean_filter(white_estimate, radius=(self.average_size + 1) / 2)
def estimate_white(self, sequences, channel_ids, dark=None):
"""Estimation of the white fluorescence image shape of synchrotron light from experimental images of Telemos microscope.