Closed mdecea closed 3 years ago
Thanks for the feedback! One reason HoloPy uses xarray is to reduce the importance of dimension ordering, since dimensions can be referred to by name rather than position. Our hope is that users don't need to worry too much about dimensions or constantly checking the shape of different objects. However, this ideal is not implemented everywhere throughout HoloPy.
Allow me to clarify the examples you mentioned:
It turns out the docstring for subimage
is actually not quite correct. If center
and/or shape
are longer than 2, any other elements will be ignored. For example: cropped = hp.core.process.subimage(holo, center=(213, 312), shape=100)
, will crop a hologram to 100 pixels in each of x & y, regardless of any other dimensions the hologram may have.
You are correct that the zero_filter
function assumes x
and y
dimensions are along axes 0 and 1. This is a bug and the function should be fixed to look at dimension names.
Hello,
I just started using the package, but I came across an issue that I find a bit confusing and that, as far as I am concerned, is not mentioned anywhere: there does not seem to be consistency between dimensions in different functions/accessing operations.
Let me try to explain:
If you get the shape of the image in the xarray object, you get
[z, x, y, num_channels]
. For example, if I have a single rgb image with 1024x2096 pixels,im.shape = [1, 1024, 2096, 3]
.Nevertheless, for image processing operations like
subimage
, you have to specify the shape in the format[x, y, z, num_channels]
. If I were to select a 512x1024 subimage, I would need to write something likehp.core.process.subimage(holo, center=(x_center, y_center, 1, 1), shape=( 512, 1024, 1, 3) )
.Something that is a bit more troubling (unless I am getting everything wrong, which is possible) is that this inconsistency seems to result in errors. For example, in the
zero_filter
function incore.process
, it seems like the interpolation is being done in the z and x axis (dimensions 0 and 1 of the xarray), while I would expect the desired functionality to be interpolation along the x and y axis (dimensions 1 and 2 of the xarray).