magni.imaging.measurements._uniform_rotated_line module¶
Module providing public functions for the magni.imaging.measurements subpackage.
Routine listings¶
 uniform_rotated_line_sample_image(h, w, scan_length, num_points, angle=0.,
 follow_edge=True) Function for uniform rotated line sampling an image.
 uniform_rotated_line_sample_surface(l, w, speed, sample_rate, time, angle=0.,
 follow_edge=True) Function for uniform rotated line sampling a surface.

magni.imaging.measurements._uniform_rotated_line.
uniform_rotated_line_sample_image
(h, w, scan_length, num_points, angle=0.0, follow_edge=True)[source]¶ Sample an image using a uniform rotated line pattern.
The coordinates (in units of pixels) resulting from sampling an image of size h times w using a uniform rotated line pattern are determined. The scan_length determines the length of the path scanned whereas num_points indicates the number of samples taken on that path.
Parameters:  h (int) – The height of the area to scan in units of pixels.
 w (int) – The width of the area to scan in units of pixels.
 scan_length (float) – The length of the path to scan in units of pixels.
 num_points (int) – The number of samples to take on the scanned path.
 angle (float) – The angle measured in radians by which the uniform lines are rotated (the default is 0.0 resulting in a pattern identical to that of uniform_line_sample_image).
 follow_edge (bool) – A flag indicating whether or not the pattern follows the edges of the rectangular area inbetween lines (the default is True).
Returns: coords (ndarray) – The coordinates of the samples arranged into a 2D array, such that each row is a coordinate pair (x, y).
Notes
The orientation of the coordinate system is such that the width w is measured along the xaxis whereas the height h is measured along the yaxis.
The angle is limited to the interval \([0;\pi)\). An angle of 0 results in the same behaviour as that of uniform_line_sample_image. An increase in the angle rotates the overall direction counterclockwise, i.e., at \(\frac{\pi}{2}\), the uniform_line_sample_image sampling pattern is rotated 90 degrees counterclockwise.
If the follow_edge flag is True, then the pattern follows the edges of the rectangular area when moving from one line to the next. If the flag is False, then the pattern follows a line perpendicular to the uniform lines when moving from one line to the next. In the latter case, some of the uniform lines are shortened to allow the described behaviour.
Examples
For example,
>>> import numpy as np >>> from magni.imaging.measurements import \ ... uniform_rotated_line_sample_image >>> h = 10 >>> w = 10 >>> scan_length = 50.0 >>> num_points = 12 >>> np.set_printoptions(suppress=True) >>> uniform_rotated_line_sample_image(h, w, scan_length, num_points) array([[ 0.5 , 0.5 ], [ 4.59090909, 0.5 ], [ 8.68181818, 0.5 ], [ 9.22727273, 3.5 ], [ 5.13636364, 3.5 ], [ 1.04545455, 3.5 ], [ 1.04545455, 6.5 ], [ 5.13636364, 6.5 ], [ 9.22727273, 6.5 ], [ 8.68181818, 9.5 ], [ 4.59090909, 9.5 ], [ 0.5 , 9.5 ]])

magni.imaging.measurements._uniform_rotated_line.
uniform_rotated_line_sample_surface
(l, w, speed, sample_rate, time, angle=0.0, follow_edge=True)[source]¶ Sample a surface area using a uniform rotated line pattern.
The coordinates (in units of meters) resulting from sampling an area of size l times w using uniform rotated line pattern are determined. The scanned path is determined from the probe speed and the scan
time
.Parameters:  l (float) – The length of the area to scan in units of meters.
 w (float) – The width of the area to scan in units of meters.
 speed (float) – The probe speed in units of meters/second.
 sample_rate (float) – The sample rate in units of Hertz.
 time (float) – The scan time in units of seconds.
 angle (float) – The angle measured in radians by which the uniform lines are rotated (the default is 0.0 resulting in a pattern identical to that of uniform_line_sample_image).
 follow_edge (bool) – A flag indicating whether or not the pattern foolows the edges of the rectangular area inbetween lines (the default is True).
Returns: coords (ndarray) – The coordinates of the samples arranged into a 2D array, such that each row is a coordinate pair (x, y).
Notes
The orientation of the coordinate system is such that the width w is measured along the xaxis whereas the length l is measured along the yaxis.
The angle is limited to the interval \([0;\pi)\). An angle of 0 results in the same behaviour as that of uniform_line_sample_surface. An increase in the angle rotates the overall direction counterclockwise, i.e., at \(\frac{\pi}{2}\), the uniform_line_sample_surface sampling pattern is rotated 90 degrees counterclockwise.
If the follow_edge flag is True, then the pattern follows the edges of the rectangular area when moving from one line to the next. If the flag is False, then the pattern follows a line perpendicular to the uniform lines when moving from one line to the next. In the latter case, some of the uniform lines are shortened to allow the described behaviour.
Examples
For example,
>>> import numpy as np >>> from magni.imaging.measurements import \ ... uniform_rotated_line_sample_surface >>> l = 1e6 >>> w = 1e6 >>> speed = 7e7 >>> sample_rate = 1.0 >>> time = 12.0 >>> np.set_printoptions(suppress=True) >>> uniform_rotated_line_sample_surface(l, w, speed, sample_rate, time) array([[ 0. , 0. ], [ 0.00000067, 0. ], [ 0.00000083, 0.00000017], [ 0.00000017, 0.00000017], [ 0.00000033, 0.00000033], [ 0.000001 , 0.00000033], [ 0.0000005 , 0.0000005 ], [ 0. , 0.00000067], [ 0.00000067, 0.00000067], [ 0.00000083, 0.00000083], [ 0.00000017, 0.00000083], [ 0.00000033, 0.000001 ], [ 0.000001 , 0.000001 ]])