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
Profile line for 3d array added to profile.py #1884
base: main
Are you sure you want to change the base?
Conversation
… be set to false when profiling a 3d array.
…or array types and multichannel options
@Korijn : |
…at). This allowed using the general method img_as_float() on all incoming arrays, 3d or 2d.
… when converting.
skimage/measure/profile.py
Outdated
perp_cols = np.array([np.linspace(col_i - col_width, col_i + col_width, | ||
linewidth) for col_i in line_col]) | ||
perp_plane = np.array([np.linspace(slice_i - slice_width, slice_i + slice_width, | ||
linewidth) for slice_i in line_slice]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use (plane, row, column) as 3D coordinates, see Coordinate conventions
@Maxyme Awesome, thank you for this contribution! It's something that's been on the back of my mind for a long time but my 3D geometry wasn't up to snuff. I've made some stylistic comments and a couple of implementation suggestions. After that I can have another stab at it. Thank you again! |
To make some of the algebra less hairy, using quaternions might be handy. This stackoverflow answer has a nice, simple implementation that could be used here. Maybe? As I said, my 3D geometry is not great! |
@jni Thanks for your corrections. I'll have another go at it today. You are correct that the sampling method does generate a denser sampling near the center of the cylinder, or disk. One way of solving this is to reduce the angle size as we move farther from the center of the cylinder. Then, we could have a similar density of sample points. |
…he distance between the point and the center of the axis increases
skimage/measure/profile.py
Outdated
rotation_angles = np.array([0]) | ||
else: | ||
rotation_angles = np.linspace(0, 2 * constants.pi, 2 * distance_point_line + 3) | ||
rotation_angles = np.delete(rotation_angles, len(rotation_angles) - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not equal to rotation_angles[:-1]
?
# Conflicts: # skimage/measure/profile.py # skimage/measure/tests/test_profile.py
fixed del last item of array
Hello @Maxyme! Thanks for updating the PR.
Comment last updated on October 16, 2018 at 19:33 Hours UTC |
added linalg module for 3d profile functions.
Codecov Report
@@ Coverage Diff @@
## master #1884 +/- ##
=========================================
- Coverage 87.61% 86.8% -0.82%
=========================================
Files 323 341 +18
Lines 27138 27454 +316
=========================================
+ Hits 23777 23831 +54
- Misses 3361 3623 +262
Continue to review full report at Codecov.
|
skimage/measure/_linalg.py
Outdated
|
||
p3 = (c * (u ** 2 + v ** 2) - w * (a * u + b * v - u * p - v * q - w * r)) * \ | ||
(1 - np.cos(angle_in_radians)) + r * np.cos(angle_in_radians) + \ | ||
(-b * u + a * v - v * p + u * q) * np.sin(angle_in_radians) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide a reference for this formula?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for the comment, I'm in the long due process of updating this PR. I will add the reference here.
# fixed Conflicts: # skimage/measure/profile.py - change from np.ceil to math.ceil to handle conversion to int.
PR resurrected from the dead! 🧟 |
@stefanv Yes, it's been too long. I've updated it a bit, but I think it still needs a thorough review. There may be duplicate or misplaced chunks of code (linalg, etc) so any suggestion in this regard is appreciated. |
I added a method to generate a profile line of a 3d array. It samples points around the direction axis, by rotating them along the same axis. The number of sample points is related to the line width. For a line width of 1 no rotation is needed.
Otherwise, the number of angles is generated like this: rotation_angles = np.linspace(0, constants.pi, (linewidth * 2) - 1)
Also, arrays are converted to float before sending to ndi_map_coordinates, because the order value would be ignored when the arrays are int.
This is my first commit, let me know of any changes required. I also assume some functions may be optimized.