Skip to content
Snippets Groups Projects
Commit 9331b28a authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Corrected Gaussian smoothing in pixel map

parent 019156dd
No related branches found
No related tags found
No related merge requests found
......@@ -107,7 +107,7 @@ class IlastikPixelClassifierParams(IlastikParams):
class IlastikPixelClassifierModel(IlastikModel, SemanticSegmentationModel):
model_id = 'ilastik_pixel_classification'
operations = ['segment', ]
def __init__(self, params: IlastikPixelClassifierParams, **kwargs):
super(IlastikPixelClassifierModel, self).__init__(params, **kwargs)
......@@ -169,7 +169,7 @@ class IlastikPixelClassifierModel(IlastikModel, SemanticSegmentationModel):
pxmap, _ = self.infer(img)
sig = self.params['px_smoothing']
if sig > 0.0:
proc = smooth(img.data, sig)
proc = smooth(pxmap.data, sig)
else:
proc = pxmap.data
mask = proc[:, :, self.params['px_class'], :] > self.params['px_prob_threshold']
......@@ -317,9 +317,11 @@ class IlastikObjectClassifierFromPixelPredictionsModel(IlastikModel, ImageToImag
"""
if not img.shape == pxmap.shape:
raise InvalidInputImageError('Expecting input image and pixel probabilities to be the same shape')
if not pxmap.data.min() >= 0.0 and pxmap.data.max() <= 1.0:
raise InvalidInputImageError('Pixel probability values must be between 0.0 and 1.0')
pxch = kwargs.get('pixel_classification_channel', 0)
pxtr = kwargs.get('pixel_classification_threshold', 0.5)
mask = pxmap.get_mono(pxch).apply(lambda x: x > pxtr)
pxtr = kwargs('pixel_classification_threshold', 0.5)
mask = InMemoryDataAccessor(pxmap.get_one_channel_data(pxch).data > pxtr)
obmap, _ = self.infer(img, mask)
return obmap
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment