Ejemplo n.º 1
0
def test_run_binary(workspace, module):
    module.object_name.value = "inputobjects"

    module.image_name.value = "outputimage"

    module.image_mode.value = "Binary (black & white)"

    module.run(workspace)

    image = workspace.image_set.get_image("outputimage")

    objects = workspace.get_objects("inputobjects")

    assert image.dimensions == objects.segmented.ndim

    pixel_data = image.pixel_data

    assert pixel_data.shape == objects.shape

    if objects.segmented.ndim is 2:
        assert not pixel_data[0, 0]

        assert numpy.all(pixel_data[:, 1:])

        assert numpy.all(pixel_data[1:, :])
    else:
        assert not numpy.all(pixel_data[:, 0, 0])

        assert numpy.all(pixel_data[:, :, 1:])

        assert numpy.all(pixel_data[:, 1:, :])
Ejemplo n.º 2
0
def test_run_uint16(workspace, module):
    module.object_name.value = "inputobjects"

    module.image_name.value = "outputimage"

    module.image_mode.value = "uint16"

    module.run(workspace)

    image = workspace.image_set.get_image("outputimage")

    objects = workspace.get_objects("inputobjects")

    assert image.dimensions == objects.segmented.ndim

    pixel_data = image.pixel_data

    assert pixel_data.shape == objects.shape

    expected = numpy.reshape(numpy.arange(256), (16, 16))

    if objects.segmented.ndim is 3:
        expected = numpy.tile(expected, (3, 1))

        expected = numpy.reshape(expected, (3, 16, 16))

    assert numpy.all(pixel_data == expected)
Ejemplo n.º 3
0
def test_run_color(workspace, module):
    for color in [
            "Default", "autumn", "bone", "colorcube", "cool", "copper", "flag",
            "gray", "hot", "hsv", "jet", "lines", "pink", "prism", "spring",
            "summer", "white", "winter"
    ]:
        module.object_name.value = "inputobjects"

        module.image_name.value = "outputimage"

        module.image_mode.value = "Color"

        module.colormap.value = color

        module.run(workspace)

        image = workspace.image_set.get_image("outputimage")

        objects = workspace.get_objects("inputobjects")

        assert image.dimensions == objects.segmented.ndim

        pixel_data = image.pixel_data

        assert pixel_data.shape == objects.shape + (3, )
def test_run_binary(workspace, module):
    module.object_name.value = "inputobjects"

    module.image_name.value = "outputimage"

    module.image_mode.value = "Binary (black & white)"

    module.run(workspace)

    image = workspace.image_set.get_image("outputimage")

    objects = workspace.get_objects("inputobjects")

    assert image.dimensions == objects.segmented.ndim

    pixel_data = image.pixel_data

    assert pixel_data.shape == objects.shape

    if objects.segmented.ndim == 2:
        assert not pixel_data[0, 0]

        assert numpy.all(pixel_data[:, 1:])

        assert numpy.all(pixel_data[1:, :])
    else:
        assert not numpy.all(pixel_data[:, 0, 0])

        assert numpy.all(pixel_data[:, :, 1:])

        assert numpy.all(pixel_data[:, 1:, :])
def test_run_uint16(workspace, module):
    module.object_name.value = "inputobjects"

    module.image_name.value = "outputimage"

    module.image_mode.value = "uint16"

    module.run(workspace)

    image = workspace.image_set.get_image("outputimage")

    objects = workspace.get_objects("inputobjects")

    assert image.dimensions == objects.segmented.ndim

    pixel_data = image.pixel_data

    assert pixel_data.shape == objects.shape

    expected = numpy.reshape(numpy.arange(256), (16, 16))

    if objects.segmented.ndim == 3:
        expected = numpy.tile(expected, (3, 1))

        expected = numpy.reshape(expected, (3, 16, 16))

    assert numpy.all(pixel_data == expected)
def test_run_color(workspace, module):
    for color in [
        "Default",
        "autumn",
        "bone",
        "colorcube",
        "cool",
        "copper",
        "flag",
        "gray",
        "hot",
        "hsv",
        "jet",
        "lines",
        "pink",
        "prism",
        "spring",
        "summer",
        "white",
        "winter"
    ]:
        module.object_name.value = "inputobjects"

        module.image_name.value = "outputimage"

        module.image_mode.value = "Color"

        module.colormap.value = color

        module.run(workspace)

        image = workspace.image_set.get_image("outputimage")

        objects = workspace.get_objects("inputobjects")

        assert image.dimensions == objects.segmented.ndim

        pixel_data = image.pixel_data

        assert pixel_data.shape == objects.shape + (3,)