Commit dee2bc9f authored by inhuszar's avatar inhuszar
Browse files

Added MeanShift to stripbg, paramlogfile to batch processor.

parent e7d8d781
......@@ -80,6 +80,7 @@ def prepare_multi_stage3(confile, yestoall):
# Adapt the configurations
cnf = AttrMap(cnf)
cnf.general.outputdir = outputdir
cnf.general.paramlogfile = os.path.join(outputdir, "paramlog.log")
# Slice
cnf.slice.file = current_slice[0]
......
......@@ -66,6 +66,7 @@ CLFLAGS = {'tiff': '--tif',
'save': '--save',
'mask': '--mask',
'median': '--median',
'meanshift': '--meanshift',
'invert': '--inv',
'corner': '--corner',
'segval': '-s',
......@@ -258,6 +259,18 @@ def main(*args):
print('Processing {}...'.format(imfile))
print(img.shape)
if argexist(CLFLAGS['meanshift']):
import cv2
arg = subarg(CLFLAGS["meanshift"], default_value=None, splitat=" ")
if arg is None:
sp, sr = 21, 51
else:
sp, sr = arg
original = img
img = cv2.pyrMeanShiftFiltering(img, float(sp), float(sr))
else:
original = None
# Prepare layers to be used as dimensions for the k-Means classifier
lstack = img
if ch != 1:
......@@ -336,6 +349,9 @@ def main(*args):
mask[mask == 0] = current_label
mask[mask == tmplabel] = 0
if original is not None:
img = original
# Area filtering
if area_limit is not None:
cleanmask = np.copy(mask)
......@@ -452,6 +468,8 @@ if __name__ == '__main__':
--mask Output the mask.
--median <size> Perform median filtering on the mask with fixed
kernel size. (default: off)
--meanshift <sp> <sr> Perform mean shift filtering on the image
before segmentation. (default: off)
--inv Invert the mask. (default: off)
--corner <c> Forces the specified corner to be labeled with
zero. (0: Top-left 1: top-right, 2: bottom-left
......
......@@ -18,6 +18,7 @@ dependencies:
- numba>=0.49.1
- numpy=1.16.5
- openblas
- opencv
- openjpeg
- openslide
- pillow
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment