src package¶
Submodules¶
src.ActiveContour module¶
- class src.ActiveContour.ActiveContour(image: list, x_coords: list = None, y_coords: list = None, alpha: float = 0.1, beta: float = 0.25, gamma: float = 1.0, kappa: float = 0.0, mu: float = 0.1, vf_iterations: int = 100, contour_iterations: int = 200)[source]¶
Bases:
object
Class that represents the snake, the contour that deforms until reaching a state of equilibrium through an optimization process. This class contains the methods needed to do that.
Methods¶
- adjustContour(perimeter_factor=None, f_close=None, plot_contour=None, fix_point_count=None,
fix_point_indices=None, f_keep_point_count=None, f_compute_convergence=None, convergence_thresh=None, convergence_metric_type=None, convergence_metric_value=None) Runs the GGVF Active Contour code to completion. It deforms iteratively the initial contour until it reaches a sate of equilibrium.
- adjustContour(perimeter_factor=None, f_close=None, plot_contour=None, fix_point_count=None, fix_point_indices=None, f_keep_point_count=None, f_compute_convergence=None, convergence_thresh=None, convergence_metric_type=None, convergence_metric_value=None) ndarray [source]¶
Runs the GGVF Active Contour code to completion. It deforms iteratively the initial contour until it reaches a sate of equilibrium.
Parameters¶
- perimeter_factor: float, optional
It indicates the factor to compute the number of points to use for a given contour, by default None.
- f_close: bool, optional
Flag to indicate if a contour must be closed, adding an extra point, by default None.
- plot_contour: int, optional
Flag to indicate if a contour must be closed, adding an extra point, by default None.
- fix_point_count: int, optional
Number of points to fix in the contour, by default None.
- fix_point_indices: np.ndarray, optional
Array of indices of the points to be fixed.
- f_keep_point_count: bool, optional
Flag to indicate that the number of points in the contour must be kept, and if False, it re-interpolates them.
- f_compute_convergence: bool, optional
Flaf to indicate that the convergence must be computed.
- convergence_thresh: float, optional
Value of the convergence limit.
- convergence_metric_type: string, optional
It indicates the type of metric to compute the variation between the contour in the current iteration and the last iteration, until reaching convergence.
- convergence_metric_value: float, optional
It indicates that the convergence must be computed, in case the flags f_compute_convergence or f_use_convergence_threshold where not set.
Returns¶
- np.ndarray
It returns an array with the coordinates x and y of the contour after the adjustment, when the state of equilibrium is reached.
- arcSample(points=50, f_close=None) None [source]¶
It takes a closed curve and re-samples it in equal arc lengths.
Parameters¶
- pointsint, optional
The number of points in the output vectors, by default 50.
- f_closebool, optional
Set this keyword to True to specify the contour curve, by default None.
- edgeMap() None [source]¶
Computes the edge map of a given image, and sets the values of the coordinates u and v of the GGVF.
- getCoords(xyRes=array([1., 1.])) ndarray [source]¶
It returns the coordinates x and y of the image.
Parameters¶
- xyResnp.ndarray of floats, optional
Resolution of the image, by default np.array([1.,1.])
Returns¶
- np.ndarray
- Coordinates x and y of the image
note:: in case xCoords is an invalid value, it returns -1.
- getDistance(xyRes=array([1., 1.])) ndarray [source]¶
This method calculates the distance between consecutive points.
Parameters:¶
- xyRes: np.ndarray of floats, optional.
Resolution of the image, by default np.array([1,1]).
Returns:¶
- np.ndarray
Array of floats with the euclidean distance between the consecutive points of a segment. note:: in case xCoords is an invalid value, it returns -1.
- getPerimeter(xyRes=array([1., 1.])) float [source]¶
This method calculates the perimeter of a contour.
Parameters:¶
- xyRes: np.ndarray of floats, optional.
Resolution of the image. Default: np.array([1,1]).
Returns:¶
- float
Value of the perimeter of a contour. note:: in case xCoords is an invalid value, it returns -1.
- get_GGVF()[source]¶
It returns the values of the GGVF, with its coordinates u and v.
Returns¶
- np.ndarray
It returns an array with the value of the GGVF.
- get_x_coords()[source]¶
It returns the array of coordinates x of the contour.
Returns¶
- np.ndarray
X coordinates of the contour.
- get_y_coords()[source]¶
It returns the array of coordinates y of the contour.
Returns¶
- np.ndarray
Y coordinates of the contour.
- gradient(image: ndarray, direction: int) ndarray [source]¶
Computes the gradient of the image’s intensity.
Parameters¶
- imagenp.ndarray
Array with the intensity values per pixel of the image.
- directionint
It indicates the direction in which to calculate the gradient.
Returns¶
- np.ndarray
Returns the result of computing the gradient of the image.
src.FilterActiveContour module¶
src.geometryFunctions module¶
- src.geometryFunctions.calcNorm_L1ForVector(vec)[source]¶
Computes the L1-norm for a vector of n components.
Parameters¶
- vecnp.ndarray
vector
Returns¶
- float
Value of the L1-norm for a vector of n components.
- src.geometryFunctions.calcNorm_L2ForVector(vec)[source]¶
Computes the L2-norm for a vector of n components.
Parameters¶
- vecnp.ndarray
vector
Returns¶
- float
Value of the L2-norm for a vector of n components.
- src.geometryFunctions.calcNorm_LInfiniteForVector(vec)[source]¶
Computes the L-infinity-norm for a vector of n components.
Parameters¶
- vecnp.ndarray
vector
Returns¶
- float
Value of the L-infinity-norm for a vector of n components.
- src.geometryFunctions.polygon_line_sample(x, y, n_points_per_pix=None, f_close_output=None, flag_vector=None, interp_flag_vector=None, f_force_zero_flag_vector=None) ndarray [source]¶
- src.geometryFunctions.polygon_perimeter(x: list, y: list, xyFactor: list = [1.0, 1.0]) ndarray [source]¶
- Computes the perimeter for a given polygon (list of 2D points).
The polygon is not required to be closed.
Parameters¶
- xlist
The input polygon x-coordinate array.
- ylist
The input polygon y-coordinate array.
- xyFactorlist, optional
Scaling factor in x and y (array of 2 elements).
Returns¶
- np.ndarray
The perimeter of the given polygon.
src.hausdorffDistanceCalc module¶
- src.hausdorffDistanceCalc.hausdorffDistanceFor2Dpoints(x1, y1, x2, y2)[source]¶
Computes the Hausdorff Distance for 2D points.
Parameters¶
- x1np.ndarray
x coordinate of point 1
- y1np.ndarray
y coordinate of point 1
- x2np.ndarray
x coordinate of point 2
- y2np.ndarray
y coordinate of point 2
Returns¶
- float
Value of the Hausdorff Distance for 2D points