clEsperanto / pyclesperanto_prototype

GPU-accelerated bio-image analysis focusing on 3D+t microscopy image data
http://clesperanto.net
BSD 3-Clause "New" or "Revised" License
208 stars 44 forks source link

Image dimensions 'transposed' when using extended_depth_of_focus_variance_projection #255

Closed jaimemcc closed 1 year ago

jaimemcc commented 1 year ago

When using extended_depth_of_focus_variance_projection the resulting image has height and width swapped, i.e. a 1000x3000 pixel image going in becomes a 3000x1000 image (not a simple rotation, the edge of the image is corrupted, see images below).

import pyclesperanto_prototype as cle
from skimage.io import imread, imsave
import numpy as np

image = np.asarray(imread("..//data//channel3.tif"))

image = np.transpose(image, (2, 0, 1)) #transpose so that Z is first dimension
print(image.shape)

result_image = None
test_image = cle.push(image)
result_image = cle.extended_depth_of_focus_variance_projection(test_image, result_image, radius_x=2, radius_y=2, sigma=10)

print(result_image.shape)

cle.imshow(result_image)
imsave("result.tif", result_image)

Input file

image

Output file

image

I noticed that the test script for this function removed a .T and uses a 5x5 matrix so maybe it is not picking this issue up (https://github.com/clEsperanto/pyclesperanto_prototype/blob/master/tests/test_extended_depth_of_focus_variance_projection.py)

haesleinhuepf commented 1 year ago

Hi @jaimemcc ,

big thanks for reporting this issue! It is now fixed in pyclesperanto_prototype 0.22.1 . You can install it using pip from now and via mamba/conda in about 24 h.

Thanks again!

Best, Robert

jaimemcc commented 1 year ago

Thanks @haesleinhuepf ! I tried it yesterday by manually updating the package and it worked great. I'm looking forward to integrating pyclesperanto into my pipelines as it's a lot more efficient than calling CLIJ through imagej macros. Thanks again for your work on the project and for responding so quickly! BW, Jaime