Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates to register_objects to allow relabelling #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
version: 0.1.0
version: 0.2.0

input:

Expand All @@ -10,6 +10,11 @@ input:
Binary or labeled mask image containing the objects
(connected pixel components) that should be registered.

- name: relabel
type: Boolean
value: false
help: >
Should objects be relabeled on registration.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a warning here that this shouldn't normally be done? Some users just seem to try out options at this is definitely an advanced feature

output:

- name: objects
Expand Down
9 changes: 6 additions & 3 deletions jtlibrary/python/jtmodules/src/jtmodules/register_objects.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2016 University of Zurich.
# Copyright 2016 Markus D. Herrmann, University of Zurich
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't see a reason to Markus back in now that you're changing the module

#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -17,16 +17,17 @@
'''
import collections
import logging
import mahotas as mh
from jtlib.utils import label

logger = logging.getLogger(__name__)

VERSION = '0.1.0'
VERSION = '0.2.0'

Output = collections.namedtuple('Output', ['objects'])


def main(mask):
def main(mask, relabel=False):
'''Registers objects (connected pixel components) in an image for use by
other (measurement) modules downstream in the pipeline. In case a binary
mask is provided the image is automatically labeled.
Expand All @@ -46,6 +47,8 @@ def main(mask):
'''
if mask.dtype == 'bool':
label_image = label(mask)
elif (relabel and mask.dtype == 'int32'):
label_image = mh.labeled.relabel(mask)[0]
else:
label_image = mask
return Output(label_image)