-
Notifications
You must be signed in to change notification settings - Fork 46
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
Affine transform: Shearing not implemented #90
Comments
Could you use an axes argument (tuple of 2 ints), as with done in the scipy.ndimage API? https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.rotate.html#scipy.ndimage.rotate |
Hey @tlambert03 , this link points to rotation, not shearing. And I can't find shearing in scipy... Anyway, I think I'll take a closer look on affine transforms in skimage. It might make sense to make the API compatible with this one. |
... and I just realized that skimage only supports 2D :-( |
Correct ... and yeah, skimage only supports 2D. I'm pretty sure I've mentioned this before, but you can have a look at my implementation at |
you can see i stopped short of provided the shearing axis as an input argument, and just hard-coded it here in the |
so basically ... my vote would be to make this all a drop-in replacement for the |
Just for the record, I'm adding the scipy affine_transform signature here:
and the clesperanto version
I'll need to think a bit about how to achieve a "drop in replacement" without breaking the interoperability with the Java side. It's tricky ;-) |
It's tricki_er_ for sure... but doable. and as I mentioned over in #91 ... I think this really gets to the heart of what kind of bridge you want to build :) One is "learn the clij way and you can use it anywhere" (which has its merits!), the other is "do it the natural way in your ecosystem ... and clij will take care of building the bridge" |
The good thing is: We're changing API-bits anyway when switching from clij to clesperanto, also on Java side. Thus, we can change the API. I just would like to make sure that these functions are no exceptional cases. The should fit in the general API style of clesperanto... In other words: All we change here, should also be possible on Java side. Otherwise it'll be a one-way bridge ;-) |
Hi @haesleinhuepf For context, I was using CLIJ to visualise the affine transformations using the CLIJ-assistant in FIJI and then export the same code to use in Python. I guess the syntax for shearing you want to adopt will depend on the audience you are targeting as well. Cheers |
Just leaving this here to continue our discussion for implementing shearing.. In regard to the shearing, the matrix will be of the form: I think we can implement shearing in x and y direction by calculating deskew factor like you did:
For shear in z along Y direction Similarly for shear in z along X, we change h(xz). I think shear operation may look something like this in clesperanto:
This is only for shear in z along the x and y direction. These are the two major ones.. Won't get time to test this today though. Will get onto this soon.. Source for matrix: https://people.cs.clemson.edu/~dhouse/courses/401/notes/affines-matrices.pdf |
Awesome, thanks @pr4deepr! You're shearing/deskewing data more often than I do, that's why I'm super excited that you proposed this API. I looks very good to me. If it works for you, feel free to submit a PR. If we know how to make it useful/handy for one plane, I'm also happy to implement it for the other planes. Let me know how it goes and if you need anything! And of course: no hurry :-) |
In the current implementation of affine transforms, shearing has not been implemented. I don't use shearing that's why I'm not sure how the API should look like. In CLIJ2 affine transforms, we used that terminology:
shearXY=[factor]: shearing along X-axis in XY plane according to given factor
shearXZ=[factor]: shearing along X-axis in XZ plane according to given factor
shearYX=[factor]: shearing along Y-axis in XY plane according to given factor
shearYZ=[factor]: shearing along Y-axis in YZ plane according to given factor
shearZX=[factor]: shearing along Z-axis in XZ plane according to given factor
shearZY=[factor]: shearing along Z-axis in YZ plane according to given factor
I'm happy to implement this here again, but I'd need someone who tests it and provides feedback.
The text was updated successfully, but these errors were encountered: