Example #1
0
def write_output(outpath, out, props, imtype='Label'):
    """Write data to an image on disk."""

    props['dtype'] = out.dtype
    if imtype == 'Label':
        mo = LabelImage(outpath, **props)
    elif imtype == 'Mask':
        mo = MaskImage(outpath, **props)
    else:
        mo = Image(outpath, **props)
    mo.create()
    mo.write(out)

    return mo
Example #2
0
def split_nucl_and_memb(labels, outpat, nuclearmask=None):

    labeldata = labels.slice_dataset()

    labeldata, labeldata_nucl = split_nucl_and_memb_data(
        labeldata, nuclearmask)

    pf = '_memb'
    outpath = outpat.format(pf)
    im_memb = LabelImage(outpath, **props)
    im_memb.create()
    im_memb.write(labeldata)

    pf = '_nucl'
    outpath = outpat.format(pf)
    im_nucl = LabelImage(outpath, **props)
    im_nucl.create()
    im_nucl.write(labeldata_nucl)

    return im_memb, im_nucl
Example #3
0
def write(out, outstem, postfix, ref_im, imtype='Image'):
    """Write an image to disk."""

    outstem = outstem or gen_outpath(ref_im, '')
    outpath = '{}{}'.format(outstem, postfix)

    props = ref_im.get_props()
    props['dtype'] = out.dtype

    if imtype == 'Label':
        mo = LabelImage(outpath, **props)
    elif imtype == 'Mask':
        mo = MaskImage(outpath, **props)
    else:
        mo = Image(outpath, **props)

    mo.create()
    mo.write(out)

    if imtype == 'Label':
        mo.set_maxlabel()
        mo.ds.attrs.create('maxlabel', mo.maxlabel, dtype='uint32')

    return mo