hughesadam87 / pyparty

Drawing and analyzing particles on images
Other
35 stars 17 forks source link

from_labels interface is convluted #21

Closed hughesadam87 closed 10 years ago

hughesadam87 commented 10 years ago

Should make a from_labels utilities that takes an image, and optionally a background. That way, doing things like:

c.from_labels( background=c.background, pbinary=False) etc... won't be as confusing. Instead, user would do.

from_labels(c.pbinary)

or to use implicit thresholding function

from_labels(c.binaryimage)

hughesadam87 commented 10 years ago

Cleaned up keywords a bit and added better description. At a glance, this method was still doing a lot of convient operations for the users, and if they need a more simple interface, it's easier to just use skimage API directly.

def from_labels(self, bgout=None, exclude=None, binary=True, pbinary=True,
                inplace=False, neighbors=4, **pmangerkwds):
    """ Get morphological labels from gray or binary image. 

    Parameters
    ----------
    exclude : 0, 1, 255, 'w', 'b'
        Exclude white, black or specified integer from labels.  For example,
        'b' will prevent black pixels from being labeled.

    bgout : Valid canvas array/color
        Background image of resulting canvas.  If exclude, then there will
        be unlabled regions.  bgout='r' will overlay the labels onto a red
        background.  By default, self.background is used.

    binary : bool
        Use binary image; else use grayimage.  

    pbinary : bool
        Use self.pbinary to generate thresholded image; else, use 
        self.threshfcn (implicit thresholding function) to binarize.
        Only valid if binary = True

    Notes
    -----
    Use binary=False with caution.  Many grayimages would lead to tends of
    thousands of labels due to minute color changes in each pixel.  Whitle
    skimage.label can handle this, pyparty will slow down severaly trying
    to make so many particles from labels.

    """