haesleinhuepf / stackview

Interactive image stack viewing in jupyter notebooks based on ipycanvas and ipywidgets
BSD 3-Clause "New" or "Revised" License
128 stars 9 forks source link

Feature request: `zoom_factor` parameter for `imshow` #59

Open haesleinhuepf opened 1 month ago

haesleinhuepf commented 1 month ago

Most stackview functions have a zoom_factor parameter. imshow does not. It might be practical to have that.

Olusesan commented 1 month ago

Do you want to set zoom_factor=1 like the other functions or do you have a specific behavior in mind?

haesleinhuepf commented 1 month ago

Hi @Olusesan , yes, it should be as similar as possible to the other functions.

Olusesan commented 1 month ago

Hi @haesleinhuepf, I forked the repo and added zoom_factor. Because plt.imshow doest have a zoom parameter, I used viewer.camera.zoom to pass the zoom_factor like below. Pls let me know your thoughts:

def imshow(..zoom_factor: float = 1):

if zoom_factor != 1.0: viewer = napari.Viewer() image = viewer.camera.zoom(image, zoom=zoom_factor)

haesleinhuepf commented 1 month ago

Hi @Olusesan ,

thanks for spending time on this! Do you think this is possible without napari? Stackview was developed to run in online environments, where napari does not work.

Also try out stackview.slice(image, zoom_factor=2) to see how zooming works in stackview.

Thanks again!

Best, Robert

Olusesan commented 1 month ago

Thanks for the guidance on this @haesleinhuepf , how about sample code below:

if zoom_factor != 1.0: image = stackview.slice(image, zoom_factor=zoom_factor)

All the best!