axeap.utils package
axeap.utils.utils module
Utility functions.
This file contains generic utility functions for doing simple simple math or string operations.
- axeap.utils.utils.getCoordsFromImage(image, area=None, subsample=None)[source]
Gets the list of non-zero pixels from an image.
- Parameters
image (array_like) – 2D array of intensity values, indexable as image[x][y].
area (array_like, optional) – Rectangular area to extract coordinates of, given as bottom left corner and top right corner in form [[x1,y1],[x2,y2]].
subsample (
float
, optional) – Fraction of points to randomly sample and return, default is to return all points.
- Returns
List of points in the form (x,y,z) where x and y are the pixel position and z is the pixel value.
- Return type
- axeap.utils.utils.get_trailing_number(s, default=None)[source]
Get number at the end of a string.
Used primarily for extracting number from filename. For example, a file whose stem is ‘Image021’ will have the number 21 extracted.
- axeap.utils.utils.linearlen(s)[source]
Get length of a span from endpoints of span.
Note
Used to make some code look nicer, but may be removed in future due it being a very simple operation.
- Parameters
s (array_like) – Span in form [x1,x2] where x1 and x2 are ends of span.
- Returns
Length of span as absolute difference between x1 and x2.
- Return type
number
- axeap.utils.utils.linearoverlap(l1, l2)[source]
Get overlap between two ranges as fraction of length of each range.
- Parameters
l1 (array_like) – First range, given in form [x1,x2] where x1 and x2 are ends of range.
l2 (array_like) – Second range, same form as l1.
- Returns
Fraction of each range that overlaps with the other, in form (fraction of l1 that overlaps, fraction of l2 that overlaps).
- Return type