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

How to change ImageScalars from volume.slice_plane() to be turned to image (numpy) ? #1150

Open
OhmPuchiss opened this issue Jun 30, 2024 · 4 comments

Comments

@OhmPuchiss
Copy link

it happens to me that I would like to create the image from multiple slice_plane()

@marcomusy
Copy link
Owner

I dont understand the question sorry.

@OhmPuchiss
Copy link
Author

vedo_issue

@OhmPuchiss
Copy link
Author

I want to export the image from slice_plane obliquely out to np.array or image data with the same resolution as the slice_plane.

@marcomusy
Copy link
Owner

Try:

from vedo import *

normal = [0, 0, 1]
cmap = "gist_stern_r"

def func(w, _):
    c, n = pcutter.origin, pcutter.normal
    vslice = vol.slice_plane(c, n, autocrop=True).cmap(cmap)
    vslice.name = "Slice"
    plt.at(1).remove("Slice").add(vslice)

    T = vslice.transform.compute_inverse()
    vslice2 = vslice.clone().apply_transform(T)
    shape = vslice2.metadata["shape"]
    arr = vslice2.pointdata["ImageScalars"].copy().reshape(shape)
    img = Image(arr).cmap(cmap)
    # img.write("slice.png")
    plt.at(2).remove("Image").add(img)


vol = Volume(dataurl + "embryo.slc").cmap(cmap)

vslice = vol.slice_plane(vol.center(), normal).cmap(cmap)
vslice.name = "Slice"

plt = Plotter(N=3, bg="k", bg2="bb", interactive=False)
plt.at(0).show(vol, zoom=1.5)

pcutter = PlaneCutter(
    vslice,
    normal=normal,
    alpha=0,
    c="white",
    padding=0,
    can_translate=False,
    can_scale=False,
)
pcutter.add_observer("interaction", func)

plt.at(1).add(pcutter)
plt.interactive().close()

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants