Пример #1
0
def rend_const():
    from gputools.utils.utils import remove_cache_dir, get_cache_dir
    remove_cache_dir()

    data = (123 * np.ones((100, 100, 100))).astype(np.float32)

    rend = VolumeRenderer((4, 4))

    rend.render(data, maxVal=200.)

    return rend
Пример #2
0
def rend_const():
    from gputools.utils.utils import remove_cache_dir, get_cache_dir
    remove_cache_dir()

    data = (123*np.ones((100,100,100))).astype(np.float32)

    rend = VolumeRenderer((4,4))

    rend.render(data, maxVal = 200.)

    return rend
Пример #3
0
def render_iso(data, t = -.8):
    from gputools.utils.utils import remove_cache_dir, get_cache_dir
    remove_cache_dir()



    rend = VolumeRenderer((400,400))

    # rend.set_occ_strength(0)
    # rend.set_occ_radius(21)
    # rend.set_occ_n_points(30)


    rend.set_modelView(mat4_translate(0, 0, t))

    rend.render(data, maxVal = 130., method="iso_surface")

    return rend
Пример #4
0
def render_iso(data, is_ao=True):
    from gputools.utils.utils import remove_cache_dir, get_cache_dir
    remove_cache_dir()

    rend = VolumeRenderer((400, 400))

    if is_ao:
        rend.set_occ_strength(1)
        rend.set_occ_radius(101)
        rend.set_occ_n_points(1000)
    else:
        rend.set_occ_strength(0)
        rend.set_occ_radius(21)
        rend.set_occ_n_points(30)

    rend.set_modelView(mat4_translate(0, 0, -1.))

    rend.render(data, maxVal=70., method="iso_surface")

    return rend
Пример #5
0
def test_simple_rendering():
    from gputools.utils.utils import remove_cache_dir, get_cache_dir
    remove_cache_dir()

    dtypes = [np.float32, np.uint16]

    # build some test data
    N = 128
    x = np.linspace(-1, 1, N)
    Z, Y, X = np.meshgrid(x, x, x, indexing="ij")
    R1 = np.sqrt((X - .2)**2 + Y**2 + Z**2)
    R2 = np.sqrt((X + .2)**2 + Y**2 + Z**2)
    data = 255 * np.exp(-30 * R1**2) + np.exp(-30 * R2**2)

    rend = VolumeRenderer((400, 400))
    outs = []

    for dtype in dtypes:
        rend.render(data=data.astype(dtype), maxVal=255.)
        outs.append(rend.output)

    # drawing

    plt.figure(1)
    plt.clf()
    for i, out in enumerate(outs):
        plt.subplot(1, len(outs), i + 1)
        plt.imshow(out)
        plt.axis("off")
        plt.title("%s" % (dtype))
    plt.pause(.1)
    plt.close()

    plt.show()
    plt.pause(.1)
    plt.close()
    return rend
Пример #6
0
def test_simple_rendering():
    from gputools.utils.utils import remove_cache_dir, get_cache_dir
    remove_cache_dir()

    dtypes = [np.float32, np.uint16]

    # build some test data
    N = 128
    x = np.linspace(-1,1,N)
    Z,Y,X = np.meshgrid(x,x,x,indexing="ij")
    R1 = np.sqrt((X-.2)**2+Y**2+Z**2)
    R2 = np.sqrt((X+.2)**2+Y**2+Z**2)
    data = 255*np.exp(-30*R1**2)+ np.exp(-30*R2**2)

    rend = VolumeRenderer((400,400))
    outs = []

    for dtype in dtypes:
        rend.render(data=data.astype(dtype), maxVal = 255.)
        outs.append(rend.output)

    # drawing

    plt.figure(1)
    plt.ion()
    plt.clf()
    for i,out in enumerate(outs):
        plt.subplot(1,len(outs),i+1)
        plt.imshow(out)
        plt.axis("off")
        plt.title("%s"%(dtype))
    plt.pause(.1)

    plt.show()
    plt.pause(1.)
    plt.close()
    return rend
Пример #7
0
#                     np.float32(1),
#                     np.float32(1),
#                     np.float32(1),
#                     np.int32(1),
#                     np.int32(1),
#                     d.data,
#                     d.data,
#                     im)
#
#     print(out.get())


if __name__ == '__main__':
    from spimagine.volumerender.volumerender import VolumeRenderer
    from gputools.utils.utils import remove_cache_dir, get_cache_dir
    remove_cache_dir()

    data = (123 * np.ones((10, 10, 10))).astype(np.float32)

    rend = VolumeRenderer((4, 4))

    rend.proc = OCLProgram("/Users/mweigert/python/spimagine/spimagine/volumerender/kernels/all_render_kernels.cl",
                           build_options=
                           ["-I", "/Users/mweigert/python/spimagine/spimagine/volumerender/kernels",
                            "-D", "maxSteps=100",
                                "-D","QUALIFIER_CONSTANT_TO_GLOBAL"
                                "-cl-finite-math-only",
                                    "-cl-fast-relaxed-math",
                                    "-cl-unsafe-math-optimizations",
                                    "-cl-mad-enable"])
Пример #8
0
    # rend.set_occ_strength(0)
    # rend.set_occ_radius(21)
    # rend.set_occ_n_points(30)


    rend.set_modelView(mat4_translate(0, 0, t))

    rend.render(data, maxVal = 130., method="iso_surface")

    return rend


if __name__ == "__main__":
    from gputools import remove_cache_dir

    remove_cache_dir()


    # build some test data
    N = 128
    x = np.linspace(-1,1,N)
    Z,Y,X = np.meshgrid(x,x,x,indexing="ij")
    R1 = np.sqrt((X-.2)**2+Y**2+Z**2)
    R2 = np.sqrt((X+.2)**2+Y**2+Z**2)
    data = 255*(np.exp(-30*R1**2)+ np.exp(-30*R2**2))
    data += np.random.uniform(0,1,data.shape)

    rend = render_iso(data, t = -0.83157894736842108)