Check out the Hyperspy Workshop May 13-17, 2024 Online

get_ellipse_model_ransac#

pyxem.utils.ransac_ellipse_tools.get_ellipse_model_ransac(data, xf=128, yf=128, rf_lim=30, semi_len_min=70, semi_len_max=90, semi_len_ratio_lim=1.2, min_samples=6, residual_threshold=10, max_trials=500, show_progressbar=True)[source]#

Pick a random number of data points to fit an ellipse to.

The ellipse’s constraints can be specified.

See skimage.measure.ransac for more information.

Parameters:
  • data (numpy.ndarray) – In the form [[[[x0, y0], [x1, y1], …]]]

  • xf, yf (scalar, optional) – Default 128 center of the diffraction pattern

  • rf_lim (scalar, optional) – How far the ellipse centre can be from (xf, yf)

  • semi_len_min, semi_len_max (scalar, optional) – Limits of the semi lengths

  • semi_len_ratio_lim (scalar, optional) – Limit of the ratio of the semi length, must be equal or larger than 1. This ratio is calculated by taking the largest semi length divided by the smallest semi length: max(semi0, semi1)/min(semi0, semi1). So for a perfect circle this ratio will be 1.

  • min_samples (scalar, optional) – Minimum number of data points to fit the ellipse model to.

  • residual_threshold (scalar, optional) – Maximum distance for a data point to be considered an inlier.

  • max_trials (scalar, optional) – Maximum number of tries for the ransac algorithm.

  • show_progressbar (bool, optional) – Default True

Returns:

ellipse_array, inlier_array – Model data is accessed in ellipse_array, where each probe position (for two axes) contain a list with the ellipse parameters: [y, x, semi_len0, semi_len1, rotation]. If no ellipse is found this is None.

Return type:

numpy.ndarray

Examples using get_ellipse_model_ransac#

Determining Elliptic Distortion

Determining Elliptic Distortion