odak.learn.tools
odak.learn.tools
Provides necessary definitions for general tools used across the library.
blur_gaussian(field, kernel_length=[21, 21], nsigma=[3, 3], padding='same')
¶
A definition to blur a field using a Gaussian kernel.
Parameters:
-
field
–MxN field.
-
kernel_length
(list
, default:[21, 21]
) –Length of the Gaussian kernel along X and Y axes.
-
nsigma
–Sigma of the Gaussian kernel along X and Y axes.
-
padding
–Padding value, see torch.nn.functional.conv2d() for more.
Returns:
-
blurred_field
(tensor
) –Blurred field.
Source code in odak/learn/tools/matrix.py
circular_binary_mask(px, py, r)
¶
Definition to generate a 2D circular binary mask.
Parameter
px : int Pixel count in x. py : int Pixel count in y. r : int Radius of the circle.
Returns:
-
mask
(tensor
) –Mask [1 x 1 x m x n].
Source code in odak/learn/tools/mask.py
convolve2d(field, kernel)
¶
Definition to convolve a field with a kernel by multiplying in frequency space.
Parameters:
-
field
–Input field with MxN shape.
-
kernel
–Input kernel with MxN shape.
Returns:
-
new_field
(tensor
) –Convolved field.
Source code in odak/learn/tools/matrix.py
correlation_2d(first_tensor, second_tensor)
¶
Definition to calculate the correlation between two tensors.
Parameters:
-
first_tensor
–First tensor.
-
second_tensor
(tensor
) –Second tensor.
Returns:
-
correlation
(tensor
) –Correlation between the two tensors.
Source code in odak/learn/tools/matrix.py
crop_center(field, size=None)
¶
Definition to crop the center of a field with 2Mx2N size. The outcome is a MxN array.
Parameters:
-
field
–Input field 2M x 2N or K x L x 2M x 2N or K x 2M x 2N x L array.
-
size
–Dimensions to crop with respect to center of the image (e.g., M x N or 1 x 1 x M x N).
Returns:
-
cropped
(ndarray
) –Cropped version of the input field.
Source code in odak/learn/tools/matrix.py
cross_product(vector1, vector2)
¶
Definition to cross product two vectors and return the resultant vector. Used method described under: http://en.wikipedia.org/wiki/Cross_product
Parameters:
-
vector1
–A vector/ray.
-
vector2
–A vector/ray.
Returns:
-
ray
(tensor
) –Array that contains starting points and cosines of a created ray.
Source code in odak/learn/tools/vector.py
distance_between_two_points(point1, point2)
¶
Definition to calculate distance between two given points.
Parameters:
-
point1
–First point in X,Y,Z.
-
point2
–Second point in X,Y,Z.
Returns:
-
distance
(Tensor
) –Distance in between given two points.
Source code in odak/learn/tools/vector.py
expanduser(filename)
¶
Definition to decode filename using namespaces and shortcuts.
Parameters:
-
filename
–Filename.
Returns:
-
new_filename
(str
) –Filename.
Source code in odak/tools/file.py
generate_2d_dirac_delta(kernel_length=[21, 21], a=[3, 3], mu=[0, 0], theta=0, normalize=False)
¶
Generate 2D Dirac delta function by using Gaussian distribution. Inspired from https://en.wikipedia.org/wiki/Dirac_delta_function
Parameters:
-
kernel_length
(list
, default:[21, 21]
) –Length of the Dirac delta function along X and Y axes.
-
a
–The scale factor in Gaussian distribution to approximate the Dirac delta function. As a approaches zero, the Gaussian distribution becomes infinitely narrow and tall at the center (x=0), approaching the Dirac delta function.
-
mu
–Mu of the Gaussian kernel along X and Y axes.
-
theta
–The rotation angle of the 2D Dirac delta function.
-
normalize
–If set True, normalize the output.
Returns:
-
kernel_2d
(tensor
) –Generated 2D Dirac delta function.
Source code in odak/learn/tools/matrix.py
generate_2d_gaussian(kernel_length=[21, 21], nsigma=[3, 3], mu=[0, 0], normalize=False)
¶
Generate 2D Gaussian kernel. Inspired from https://stackoverflow.com/questions/29731726/how-to-calculate-a-gaussian-kernel-matrix-efficiently-in-numpy
Parameters:
-
kernel_length
(list
, default:[21, 21]
) –Length of the Gaussian kernel along X and Y axes.
-
nsigma
–Sigma of the Gaussian kernel along X and Y axes.
-
mu
–Mu of the Gaussian kernel along X and Y axes.
-
normalize
–If set True, normalize the output.
Returns:
-
kernel_2d
(tensor
) –Generated Gaussian kernel.
Source code in odak/learn/tools/matrix.py
get_rotation_matrix(tilt_angles=[0.0, 0.0, 0.0], tilt_order='XYZ')
¶
Function to generate rotation matrix for given tilt angles and tilt order.
Parameters:
-
tilt_angles
–Tilt angles in degrees along XYZ axes.
-
tilt_order
–Rotation order (e.g., XYZ, XZY, ZXY, YXZ, ZYX).
Returns:
-
rotmat
(tensor
) –Rotation matrix.
Source code in odak/learn/tools/transformation.py
grid_sample(no=[10, 10], size=[100.0, 100.0], center=[0.0, 0.0, 0.0], angles=[0.0, 0.0, 0.0])
¶
Definition to generate samples over a surface.
Parameters:
-
no
–Number of samples.
-
size
–Physical size of the surface.
-
center
–Center location of the surface.
-
angles
–Tilt of the surface.
Returns:
-
samples
(tensor
) –Samples generated.
-
rotx
(tensor
) –Rotation matrix at X axis.
-
roty
(tensor
) –Rotation matrix at Y axis.
-
rotz
(tensor
) –Rotation matrix at Z axis.
Source code in odak/learn/tools/sample.py
histogram_loss(frame, ground_truth, bins=32, limits=[0.0, 1.0])
¶
Function for evaluating a frame against a target using histogram.
Parameters:
-
frame
–Input frame [1 x 3 x m x n] or [3 x m x n] or [1 x m x n] or [m x n].
-
ground_truth
–Ground truth [1 x 3 x m x n] or [3 x m x n] or [1 x m x n] or [m x n].
-
bins
–Number of bins.
-
limits
–Limits.
Returns:
-
loss
(float
) –Loss from evaluation.
Source code in odak/learn/tools/loss.py
load_image(fn, normalizeby=0.0, torch_style=False)
¶
Definition to load an image from a given location as a torch tensor.
Parameters:
-
fn
–Filename.
-
normalizeby
–Value to to normalize images with. Default value of zero will lead to no normalization.
-
torch_style
–If set True, it will load an image mxnx3 as 3xmxn.
Returns:
-
image
(ndarray
) –Image loaded as a Numpy array.
Source code in odak/learn/tools/file.py
michelson_contrast(image, roi_high, roi_low)
¶
A function to calculate michelson contrast ratio of given region of interests of the image.
Parameters:
-
image
–Image to be tested [1 x 3 x m x n] or [3 x m x n] or [m x n].
-
roi_high
–Corner locations of the roi for high intensity area [m_start, m_end, n_start, n_end].
-
roi_low
–Corner locations of the roi for low intensity area [m_start, m_end, n_start, n_end].
Returns:
-
result
(tensor
) –Michelson contrast for the given regions. [1] or [3] depending on input image.
Source code in odak/learn/tools/loss.py
multi_scale_total_variation_loss(frame, levels=3)
¶
Function for evaluating a frame against a target using multi scale total variation approach. Here, multi scale refers to image pyramid of an input frame, where at each level image resolution is half of the previous level.
Parameters:
-
frame
–Input frame [1 x 3 x m x n] or [3 x m x n] or [m x n].
-
levels
–Number of levels to go in the image pyriamid.
Returns:
-
loss
(float
) –Loss from evaluation.
Source code in odak/learn/tools/loss.py
quantize(image_field, bits=8, limits=[0.0, 1.0])
¶
Definition to quantize a image field (0-255, 8 bit) to a certain bits level.
Parameters:
-
image_field
(tensor
) –Input image field between any range.
-
bits
–A value in between one to eight.
-
limits
–The minimum and maximum of the image_field variable.
Returns:
-
new_field
(tensor
) –Quantized image field.
Source code in odak/learn/tools/matrix.py
radial_basis_function(value, epsilon=0.5)
¶
Function to pass a value into radial basis function with Gaussian description.
Parameters:
-
value
–Value(s) to pass to the radial basis function.
-
epsilon
–Epsilon used in the Gaussian radial basis function (e.g., y=e^(-(epsilon x value)^2).
Returns:
-
output
(tensor
) –Output values.
Source code in odak/learn/tools/loss.py
resize(image, multiplier=0.5, mode='nearest')
¶
Definition to resize an image.
Parameters:
-
image
–Image with MxNx3 resolution.
-
multiplier
–Multiplier used in resizing operation (e.g., 0.5 is half size in one axis).
-
mode
–Mode to be used in scaling, nearest, bilinear, etc.
Returns:
-
new_image
(tensor
) –Resized image.
Source code in odak/learn/tools/file.py
rotate_points(point, angles=torch.tensor([[0, 0, 0]]), mode='XYZ', origin=torch.tensor([[0, 0, 0]]), offset=torch.tensor([[0, 0, 0]]))
¶
Definition to rotate a given point. Note that rotation is always with respect to 0,0,0.
Parameters:
-
point
–A point with size of [3] or [1, 3] or [m, 3].
-
angles
–Rotation angles in degrees.
-
mode
–Rotation mode determines ordering of the rotations at each axis. There are XYZ,YXZ,ZXY and ZYX modes.
-
origin
–Reference point for a rotation. Expected size is [3] or [1, 3].
-
offset
–Shift with the given offset. Expected size is [3] or [1, 3] or [m, 3].
Returns:
-
result
(tensor
) –Result of the rotation [1 x 3] or [m x 3].
-
rotx
(tensor
) –Rotation matrix along X axis [3 x 3].
-
roty
(tensor
) –Rotation matrix along Y axis [3 x 3].
-
rotz
(tensor
) –Rotation matrix along Z axis [3 x 3].
Source code in odak/learn/tools/transformation.py
rotmatx(angle)
¶
Definition to generate a rotation matrix along X axis.
Parameters:
-
angle
–Rotation angles in degrees.
Returns:
-
rotx
(tensor
) –Rotation matrix along X axis.
Source code in odak/learn/tools/transformation.py
rotmaty(angle)
¶
Definition to generate a rotation matrix along Y axis.
Parameters:
-
angle
–Rotation angles in degrees.
Returns:
-
roty
(tensor
) –Rotation matrix along Y axis.
Source code in odak/learn/tools/transformation.py
rotmatz(angle)
¶
Definition to generate a rotation matrix along Z axis.
Parameters:
-
angle
–Rotation angles in degrees.
Returns:
-
rotz
(tensor
) –Rotation matrix along Z axis.
Source code in odak/learn/tools/transformation.py
same_side(p1, p2, a, b)
¶
Definition to figure which side a point is on with respect to a line and a point. See http://www.blackpawn.com/texts/pointinpoly/ for more. If p1 and p2 are on the sameside, this definition returns True.
Parameters:
-
p1
–Point(s) to check.
-
p2
–This is the point check against.
-
a
–First point that forms the line.
-
b
–Second point that forms the line.
Source code in odak/learn/tools/vector.py
save_image(fn, img, cmin=0, cmax=255, color_depth=8)
¶
Definition to save a torch tensor as an image.
Parameters:
-
fn
–Filename.
-
img
–A numpy array with NxMx3 or NxMx1 shapes.
-
cmin
–Minimum value that will be interpreted as 0 level in the final image.
-
cmax
–Maximum value that will be interpreted as 255 level in the final image.
-
color_depth
–Color depth of an image. Default is eight.
Returns:
-
bool
(bool
) –True if successful.
Source code in odak/learn/tools/file.py
save_torch_tensor(fn, tensor)
¶
Definition to save a torch tensor.
Parameters:
-
fn
–Filename.
-
tensor
–Torch tensor to be saved.
tilt_towards(location, lookat)
¶
Definition to tilt surface normal of a plane towards a point.
Parameters:
-
location
–Center of the plane to be tilted.
-
lookat
–Tilt towards this point.
Returns:
-
angles
(list
) –Rotation angles in degrees.
Source code in odak/learn/tools/transformation.py
torch_load(fn, weights_only=True)
¶
Definition to load a torch files (*.pt).
Parameters:
-
fn
–Filename.
-
weights_only
(bool
, default:True
) –See torch.load() for details.
Returns:
-
data
(any
) –See torch.load() for more.
Source code in odak/learn/tools/file.py
total_variation_loss(frame)
¶
Function for evaluating a frame against a target using total variation approach.
Parameters:
-
frame
–Input frame [1 x 3 x m x n] or [3 x m x n] or [m x n].
Returns:
-
loss
(float
) –Loss from evaluation.
Source code in odak/learn/tools/loss.py
weber_contrast(image, roi_high, roi_low)
¶
A function to calculate weber contrast ratio of given region of interests of the image.
Parameters:
-
image
–Image to be tested [1 x 3 x m x n] or [3 x m x n] or [1 x m x n] or [m x n].
-
roi_high
–Corner locations of the roi for high intensity area [m_start, m_end, n_start, n_end].
-
roi_low
–Corner locations of the roi for low intensity area [m_start, m_end, n_start, n_end].
Returns:
-
result
(tensor
) –Weber contrast for given regions. [1] or [3] depending on input image.
Source code in odak/learn/tools/loss.py
wrapped_mean_squared_error(image, ground_truth, reduction='mean')
¶
A function to calculate the wrapped mean squared error between predicted and target angles.
Parameters:
-
image
–Image to be tested [1 x 3 x m x n] or [3 x m x n] or [1 x m x n] or [m x n].
-
ground_truth
–Ground truth to be tested [1 x 3 x m x n] or [3 x m x n] or [1 x m x n] or [m x n].
-
reduction
–Specifies the reduction to apply to the output: 'mean' (default) or 'sum'.
Returns:
-
wmse
(tensor
) –The calculated wrapped mean squared error.
Source code in odak/learn/tools/loss.py
zero_pad(field, size=None, method='center')
¶
Definition to zero pad a MxN array to 2Mx2N array.
Parameters:
-
field
–Input field MxN or KxJxMxN or KxMxNxJ array.
-
size
–Size to be zeropadded (e.g., [m, n], last two dimensions only).
-
method
–Zeropad either by placing the content to center or to the left.
Returns:
-
field_zero_padded
(ndarray
) –Zeropadded version of the input field.
Source code in odak/learn/tools/matrix.py
load_image(fn, normalizeby=0.0, torch_style=False)
¶
Definition to load an image from a given location as a torch tensor.
Parameters:
-
fn
–Filename.
-
normalizeby
–Value to to normalize images with. Default value of zero will lead to no normalization.
-
torch_style
–If set True, it will load an image mxnx3 as 3xmxn.
Returns:
-
image
(ndarray
) –Image loaded as a Numpy array.
Source code in odak/learn/tools/file.py
resize(image, multiplier=0.5, mode='nearest')
¶
Definition to resize an image.
Parameters:
-
image
–Image with MxNx3 resolution.
-
multiplier
–Multiplier used in resizing operation (e.g., 0.5 is half size in one axis).
-
mode
–Mode to be used in scaling, nearest, bilinear, etc.
Returns:
-
new_image
(tensor
) –Resized image.
Source code in odak/learn/tools/file.py
save_image(fn, img, cmin=0, cmax=255, color_depth=8)
¶
Definition to save a torch tensor as an image.
Parameters:
-
fn
–Filename.
-
img
–A numpy array with NxMx3 or NxMx1 shapes.
-
cmin
–Minimum value that will be interpreted as 0 level in the final image.
-
cmax
–Maximum value that will be interpreted as 255 level in the final image.
-
color_depth
–Color depth of an image. Default is eight.
Returns:
-
bool
(bool
) –True if successful.
Source code in odak/learn/tools/file.py
save_torch_tensor(fn, tensor)
¶
Definition to save a torch tensor.
Parameters:
-
fn
–Filename.
-
tensor
–Torch tensor to be saved.
torch_load(fn, weights_only=True)
¶
Definition to load a torch files (*.pt).
Parameters:
-
fn
–Filename.
-
weights_only
(bool
, default:True
) –See torch.load() for details.
Returns:
-
data
(any
) –See torch.load() for more.
Source code in odak/learn/tools/file.py
histogram_loss(frame, ground_truth, bins=32, limits=[0.0, 1.0])
¶
Function for evaluating a frame against a target using histogram.
Parameters:
-
frame
–Input frame [1 x 3 x m x n] or [3 x m x n] or [1 x m x n] or [m x n].
-
ground_truth
–Ground truth [1 x 3 x m x n] or [3 x m x n] or [1 x m x n] or [m x n].
-
bins
–Number of bins.
-
limits
–Limits.
Returns:
-
loss
(float
) –Loss from evaluation.
Source code in odak/learn/tools/loss.py
michelson_contrast(image, roi_high, roi_low)
¶
A function to calculate michelson contrast ratio of given region of interests of the image.
Parameters:
-
image
–Image to be tested [1 x 3 x m x n] or [3 x m x n] or [m x n].
-
roi_high
–Corner locations of the roi for high intensity area [m_start, m_end, n_start, n_end].
-
roi_low
–Corner locations of the roi for low intensity area [m_start, m_end, n_start, n_end].
Returns:
-
result
(tensor
) –Michelson contrast for the given regions. [1] or [3] depending on input image.
Source code in odak/learn/tools/loss.py
multi_scale_total_variation_loss(frame, levels=3)
¶
Function for evaluating a frame against a target using multi scale total variation approach. Here, multi scale refers to image pyramid of an input frame, where at each level image resolution is half of the previous level.
Parameters:
-
frame
–Input frame [1 x 3 x m x n] or [3 x m x n] or [m x n].
-
levels
–Number of levels to go in the image pyriamid.
Returns:
-
loss
(float
) –Loss from evaluation.
Source code in odak/learn/tools/loss.py
radial_basis_function(value, epsilon=0.5)
¶
Function to pass a value into radial basis function with Gaussian description.
Parameters:
-
value
–Value(s) to pass to the radial basis function.
-
epsilon
–Epsilon used in the Gaussian radial basis function (e.g., y=e^(-(epsilon x value)^2).
Returns:
-
output
(tensor
) –Output values.
Source code in odak/learn/tools/loss.py
total_variation_loss(frame)
¶
Function for evaluating a frame against a target using total variation approach.
Parameters:
-
frame
–Input frame [1 x 3 x m x n] or [3 x m x n] or [m x n].
Returns:
-
loss
(float
) –Loss from evaluation.
Source code in odak/learn/tools/loss.py
weber_contrast(image, roi_high, roi_low)
¶
A function to calculate weber contrast ratio of given region of interests of the image.
Parameters:
-
image
–Image to be tested [1 x 3 x m x n] or [3 x m x n] or [1 x m x n] or [m x n].
-
roi_high
–Corner locations of the roi for high intensity area [m_start, m_end, n_start, n_end].
-
roi_low
–Corner locations of the roi for low intensity area [m_start, m_end, n_start, n_end].
Returns:
-
result
(tensor
) –Weber contrast for given regions. [1] or [3] depending on input image.
Source code in odak/learn/tools/loss.py
wrapped_mean_squared_error(image, ground_truth, reduction='mean')
¶
A function to calculate the wrapped mean squared error between predicted and target angles.
Parameters:
-
image
–Image to be tested [1 x 3 x m x n] or [3 x m x n] or [1 x m x n] or [m x n].
-
ground_truth
–Ground truth to be tested [1 x 3 x m x n] or [3 x m x n] or [1 x m x n] or [m x n].
-
reduction
–Specifies the reduction to apply to the output: 'mean' (default) or 'sum'.
Returns:
-
wmse
(tensor
) –The calculated wrapped mean squared error.
Source code in odak/learn/tools/loss.py
blur_gaussian(field, kernel_length=[21, 21], nsigma=[3, 3], padding='same')
¶
A definition to blur a field using a Gaussian kernel.
Parameters:
-
field
–MxN field.
-
kernel_length
(list
, default:[21, 21]
) –Length of the Gaussian kernel along X and Y axes.
-
nsigma
–Sigma of the Gaussian kernel along X and Y axes.
-
padding
–Padding value, see torch.nn.functional.conv2d() for more.
Returns:
-
blurred_field
(tensor
) –Blurred field.
Source code in odak/learn/tools/matrix.py
convolve2d(field, kernel)
¶
Definition to convolve a field with a kernel by multiplying in frequency space.
Parameters:
-
field
–Input field with MxN shape.
-
kernel
–Input kernel with MxN shape.
Returns:
-
new_field
(tensor
) –Convolved field.
Source code in odak/learn/tools/matrix.py
correlation_2d(first_tensor, second_tensor)
¶
Definition to calculate the correlation between two tensors.
Parameters:
-
first_tensor
–First tensor.
-
second_tensor
(tensor
) –Second tensor.
Returns:
-
correlation
(tensor
) –Correlation between the two tensors.
Source code in odak/learn/tools/matrix.py
crop_center(field, size=None)
¶
Definition to crop the center of a field with 2Mx2N size. The outcome is a MxN array.
Parameters:
-
field
–Input field 2M x 2N or K x L x 2M x 2N or K x 2M x 2N x L array.
-
size
–Dimensions to crop with respect to center of the image (e.g., M x N or 1 x 1 x M x N).
Returns:
-
cropped
(ndarray
) –Cropped version of the input field.
Source code in odak/learn/tools/matrix.py
generate_2d_dirac_delta(kernel_length=[21, 21], a=[3, 3], mu=[0, 0], theta=0, normalize=False)
¶
Generate 2D Dirac delta function by using Gaussian distribution. Inspired from https://en.wikipedia.org/wiki/Dirac_delta_function
Parameters:
-
kernel_length
(list
, default:[21, 21]
) –Length of the Dirac delta function along X and Y axes.
-
a
–The scale factor in Gaussian distribution to approximate the Dirac delta function. As a approaches zero, the Gaussian distribution becomes infinitely narrow and tall at the center (x=0), approaching the Dirac delta function.
-
mu
–Mu of the Gaussian kernel along X and Y axes.
-
theta
–The rotation angle of the 2D Dirac delta function.
-
normalize
–If set True, normalize the output.
Returns:
-
kernel_2d
(tensor
) –Generated 2D Dirac delta function.
Source code in odak/learn/tools/matrix.py
generate_2d_gaussian(kernel_length=[21, 21], nsigma=[3, 3], mu=[0, 0], normalize=False)
¶
Generate 2D Gaussian kernel. Inspired from https://stackoverflow.com/questions/29731726/how-to-calculate-a-gaussian-kernel-matrix-efficiently-in-numpy
Parameters:
-
kernel_length
(list
, default:[21, 21]
) –Length of the Gaussian kernel along X and Y axes.
-
nsigma
–Sigma of the Gaussian kernel along X and Y axes.
-
mu
–Mu of the Gaussian kernel along X and Y axes.
-
normalize
–If set True, normalize the output.
Returns:
-
kernel_2d
(tensor
) –Generated Gaussian kernel.
Source code in odak/learn/tools/matrix.py
quantize(image_field, bits=8, limits=[0.0, 1.0])
¶
Definition to quantize a image field (0-255, 8 bit) to a certain bits level.
Parameters:
-
image_field
(tensor
) –Input image field between any range.
-
bits
–A value in between one to eight.
-
limits
–The minimum and maximum of the image_field variable.
Returns:
-
new_field
(tensor
) –Quantized image field.
Source code in odak/learn/tools/matrix.py
zero_pad(field, size=None, method='center')
¶
Definition to zero pad a MxN array to 2Mx2N array.
Parameters:
-
field
–Input field MxN or KxJxMxN or KxMxNxJ array.
-
size
–Size to be zeropadded (e.g., [m, n], last two dimensions only).
-
method
–Zeropad either by placing the content to center or to the left.
Returns:
-
field_zero_padded
(ndarray
) –Zeropadded version of the input field.
Source code in odak/learn/tools/matrix.py
grid_sample(no=[10, 10], size=[100.0, 100.0], center=[0.0, 0.0, 0.0], angles=[0.0, 0.0, 0.0])
¶
Definition to generate samples over a surface.
Parameters:
-
no
–Number of samples.
-
size
–Physical size of the surface.
-
center
–Center location of the surface.
-
angles
–Tilt of the surface.
Returns:
-
samples
(tensor
) –Samples generated.
-
rotx
(tensor
) –Rotation matrix at X axis.
-
roty
(tensor
) –Rotation matrix at Y axis.
-
rotz
(tensor
) –Rotation matrix at Z axis.
Source code in odak/learn/tools/sample.py
get_rotation_matrix(tilt_angles=[0.0, 0.0, 0.0], tilt_order='XYZ')
¶
Function to generate rotation matrix for given tilt angles and tilt order.
Parameters:
-
tilt_angles
–Tilt angles in degrees along XYZ axes.
-
tilt_order
–Rotation order (e.g., XYZ, XZY, ZXY, YXZ, ZYX).
Returns:
-
rotmat
(tensor
) –Rotation matrix.
Source code in odak/learn/tools/transformation.py
rotate_points(point, angles=torch.tensor([[0, 0, 0]]), mode='XYZ', origin=torch.tensor([[0, 0, 0]]), offset=torch.tensor([[0, 0, 0]]))
¶
Definition to rotate a given point. Note that rotation is always with respect to 0,0,0.
Parameters:
-
point
–A point with size of [3] or [1, 3] or [m, 3].
-
angles
–Rotation angles in degrees.
-
mode
–Rotation mode determines ordering of the rotations at each axis. There are XYZ,YXZ,ZXY and ZYX modes.
-
origin
–Reference point for a rotation. Expected size is [3] or [1, 3].
-
offset
–Shift with the given offset. Expected size is [3] or [1, 3] or [m, 3].
Returns:
-
result
(tensor
) –Result of the rotation [1 x 3] or [m x 3].
-
rotx
(tensor
) –Rotation matrix along X axis [3 x 3].
-
roty
(tensor
) –Rotation matrix along Y axis [3 x 3].
-
rotz
(tensor
) –Rotation matrix along Z axis [3 x 3].
Source code in odak/learn/tools/transformation.py
rotmatx(angle)
¶
Definition to generate a rotation matrix along X axis.
Parameters:
-
angle
–Rotation angles in degrees.
Returns:
-
rotx
(tensor
) –Rotation matrix along X axis.
Source code in odak/learn/tools/transformation.py
rotmaty(angle)
¶
Definition to generate a rotation matrix along Y axis.
Parameters:
-
angle
–Rotation angles in degrees.
Returns:
-
roty
(tensor
) –Rotation matrix along Y axis.
Source code in odak/learn/tools/transformation.py
rotmatz(angle)
¶
Definition to generate a rotation matrix along Z axis.
Parameters:
-
angle
–Rotation angles in degrees.
Returns:
-
rotz
(tensor
) –Rotation matrix along Z axis.
Source code in odak/learn/tools/transformation.py
tilt_towards(location, lookat)
¶
Definition to tilt surface normal of a plane towards a point.
Parameters:
-
location
–Center of the plane to be tilted.
-
lookat
–Tilt towards this point.
Returns:
-
angles
(list
) –Rotation angles in degrees.
Source code in odak/learn/tools/transformation.py
cross_product(vector1, vector2)
¶
Definition to cross product two vectors and return the resultant vector. Used method described under: http://en.wikipedia.org/wiki/Cross_product
Parameters:
-
vector1
–A vector/ray.
-
vector2
–A vector/ray.
Returns:
-
ray
(tensor
) –Array that contains starting points and cosines of a created ray.
Source code in odak/learn/tools/vector.py
distance_between_two_points(point1, point2)
¶
Definition to calculate distance between two given points.
Parameters:
-
point1
–First point in X,Y,Z.
-
point2
–Second point in X,Y,Z.
Returns:
-
distance
(Tensor
) –Distance in between given two points.
Source code in odak/learn/tools/vector.py
same_side(p1, p2, a, b)
¶
Definition to figure which side a point is on with respect to a line and a point. See http://www.blackpawn.com/texts/pointinpoly/ for more. If p1 and p2 are on the sameside, this definition returns True.
Parameters:
-
p1
–Point(s) to check.
-
p2
–This is the point check against.
-
a
–First point that forms the line.
-
b
–Second point that forms the line.