matchpoint.core.MatchPoint#
- class matchpoint.core.MatchPoint(source=None, destination=None, method=None, transformation_type='affine', initial_transformation=None, transformation=None, transformation_inverse=None, source_name='source', destination_name='destination', source_unit=None, destination_unit=None, destination_distance_threshold=0, name=None)#
Mapping class to find, improve, store and use a mapping between a source point set and a destination point set.
- source#
Source coordinates.
- Type:
Nx2 numpy.ndarray
- destination#
Destination coordinates.
- Type:
Nx2 numpy.ndarray
- method#
Method for finding the transformation between source and destination.
- Type:
str
- transformation_type#
Type of transformation used. Choose from: affine (default), similarity or polynomial.
- Type:
str
- initial_transformation#
Initial transformation used as starting point by the perform_mapping method. Can be given as dictionary specifying translation, scale, rotation and shear.
- Type:
skimage.transform._geometric.GeometricTransformordict
- transformation#
Transformation relating the source and destionaton point sets. Can be given as dictionary specifying translation, scale, rotation and shear.
- Type:
skimage.transform._geometric.GeometricTransformordict
- transformation_inverse#
Inverse transformation. Can be given as dictionary specifying translation, scale, rotation and shear.
- Type:
skimage.transform._geometric.GeometricTransformordict
- source_name#
Name of the source. Default is ‘source’.
- Type:
str
- destination_name#
Name of the source. Default is ‘destination_name’.
- Type:
str
- source_unit#
Unit of the source coordinates.
- Type:
str
- destination_unit#
Unit of the destination coordinates.
- Type:
str
- destination_distance_threshold#
Distance threshold in destination units for determining matched pairs between source and destination.
- Type:
float
- name#
Name of the mapping, used as the default filename when saving the mapping object.
- Type:
str
- label#
Additional attribute to store information.
- Type:
str
- matched_pairs#
Array with the indices of source points and destination points that are matched.
- Type:
Nx2 numpy.ndarray
- save_path#
Path to the folder where the MatchPoint objects is or should be saved.
- Type:
pathlib2.Path
- __init__(source=None, destination=None, method=None, transformation_type='affine', initial_transformation=None, transformation=None, transformation_inverse=None, source_name='source', destination_name='destination', source_unit=None, destination_unit=None, destination_distance_threshold=0, name=None)#
Initialize a MatchPoint object
- Parameters:
source (
Nx2 numpy.ndarray) – Source coordinates.destination (
Nx2 numpy.ndarray) – Destination coordinates.method (
str, optional) – Method for finding the transformation between source and destination.transformation_type (
str) – Type of transformation used. Choose from: affine (default), similarity or polynomial.initial_transformation (
skimage.transform._geometric.GeometricTransformordict, optional) – Initial transformation used as starting point by the perform_mapping method. Can be given as dictionary specifying translation, scale, rotation and shear.transformation (
skimage.transform._geometric.GeometricTransformordict, optional) – Transformation relating the source and destionaton point sets. Can be given as dictionary specifying translation, scale, rotation and shear.transformation_inverse (
skimage.transform._geometric.GeometricTransformordict, optional) – Inverse transformation. Can be given as dictionary specifying translation, scale, rotation and shear.source_name (
str, optional) – Name of the source. Default is ‘source’.destination_name (
str, optional) – Name of the source. Default is ‘destination_name’.source_unit (
str, optional) – Unit of the source coordinates.destination_unit (
str, optional) – Unit of the destination coordinates.destination_distance_threshold (
float) – Distance threshold in destination units for determining matched pairs between source and destination.name (
str) – Name of the mapping, used as the default filename when saving the mapping object.
Methods
Ripleys_K([crop, space])Ripleys_L_minus_d([crop, space, plot])Ripleys_L_minus_d_max([crop, space])__init__([source, destination, method, ...])Initialize a MatchPoint object
Calculates the reverse transformation from the forward transformation.
cross_correlation([peak_detection, ...])Perform cross correlation on synthesized images of the two datasets.
density_destination([crop, space])Destination density estimation from the number of points and the area contained within the convex hull.
density_source([crop, space])Source density estimation from the number of points and the area contained within the convex hull.
determine_matched_pairs([...])Find pairs of source and destination points that closer than the distance threshold and are singly matched, i.e. each source point only has one destination point within the threshold and vice versa.
direct_match([transformation_type])Find transformation from source to destination points by matching based on the point order
distance_matrix([crop, space, margin, ...])Distance matrix for all point combinations of the source and destination.
find_distance_threshold([method])Find distance optimal distance threshold and automatically sets the destination distance threshold.
fraction_of_destination_matched([crop])Fraction of the destination points that is matched to a source point
fraction_of_source_matched([crop])Fraction of the source points that is matched to a destination point
geometric_hashing([method, tuple_size, ...])Perform mapping by geometric hashing.
get_destination([crop, space, margin])Getter for the destination point set.
get_destination_area([crop, space])Get the area of the destination point set, i.e. within the destination point vertices.
get_destination_vertices([crop, space, margin])Getter for vertices of the destination point set.
get_overlap_vertices([space])Getter for vertices of the overlap between the source and destination point sets.
get_source([crop, space, margin])Getter for the source point set.
get_source_area([crop, space])Get the area of the source point set, i.e. within the source point vertices.
get_source_vertices([crop, space, margin])Getter for vertices of the source point set.
get_transformation_direction(direction)Get inverse parameter based on direction
get_unit(space)Get the unit of the source or destination point set.
get_unit_label(space)Get the string to add the axis label during plotting.
iterative_closest_point([...])Find transformation from source to destination points using an iterative closest point algorithm
kernel_correlation([bounds, sigma, crop, plot])Find transformation from source to destination points using an kernel correlation algorithm.
kernel_correlation_score([sigma, crop, ...])Determine the kernel correlation score for the current transformation.
load(filepath)Load a saved MatchPoint object
nearest_neighbour_match([...])Find transformation from source to destination points by matching nearest neighbours.
Gives the number of source and destination points that respectively have a specified number of matches with the destination and source point sets.
The number of singly-matched pairs for the provided distance thresholds.
pair_coordinates([point_set_name, space])Get the coordinates of the paired source or destination points.
pair_distances([space, show])Distances between the paired source and destination points.
perform_mapping([method])Find transformation from source to destination points using one of the mapping methods
save([save_path, filetype])Save the current mapping in a file, so that it can be opened later.
Manually set the peak coordinates after cross-cross correlation.
show([axis, show_source, show_destination, ...])Show the mapping.
show_destination(**kwargs)Plot the destination point set.
show_mapping_transformation(*args, **kwargs)Show the mapping.
show_outline([inverse, source_colour, ...])Show the outline or border of the point sets.
show_source(**kwargs)Plot the source point set.
simulate([number_of_points, transformation, ...])Simulate a point set with a specific transformation and return as a MatchPoint object.
single_match_optimization([maximum_radius, ...])Find the distance threshold with the highest number of singly matched pairs.
transform_coordinates(coordinates[, ...])Transform coordinates using the object's transformation.
transform_image(image[, inverse, direction])Transform an image using the objects transformation.
Attributes
- Ripleys_K(crop=True, space='destination')#
- Ripleys_L_minus_d(crop=True, space='destination', plot=False)#
- Ripleys_L_minus_d_max(crop=True, space='destination')#
- calculate_inverse_transformation()#
Calculates the reverse transformation from the forward transformation.
Sets the object’s transformation_inverse attribute.
Note
This is only possible for linear transformations.
- cross_correlation(peak_detection='auto', kernel_size=7, gaussian_sigma=1, divider=5, crop=False, space='destination', normalize=False, subtract_background=True, plot=False, axes=None)#
Perform cross correlation on synthesized images of the two datasets.
The current transformation is used as a starting point. Because cross-correlation only varies translation, other transformation parameters such rotation and scale should already be correct. The found transformation is stored in the object’s transformation attribute.
- Parameters:
peak_detection (
str) – If ‘auto’: the cross-correlation peak is automatically determined by finding the most intense pixel in the cross-correlation image. If ‘manual’: cross-correlation image is created, but the peak has to be determined manually. The found pixel coordinates of the peak in the image can be set using the method ‘set_correlation_peak_coordinates’, the correct transformation will then be calculated.kernel_size (
int) – The size in pixels of the gaussian kernel. The kernel will have shape (kernel_size x kernel_size).gaussian_sigma (
float) – The standard deviation of the gaussian kernel. The same standard deviation is used for x and y.divider (
intorfloat) – The number by which the point set coordinates are divided to obtain pixel indices. (Translating the lowest coordinates to the pixel (0,0) is done automatically.)crop (
intorfloat, optional) – If True: the overlap between the source and destination point set is used. If ‘source’: only the source is cropped to the destination point set. If ‘destination’: only the destination is cropped to the source point set. If False: no cropping is applied.space (
str, optional) – In which coordinate space to perform the correlation. Either ‘source’ or ‘destination’.normalize (
bool, optional) – If True, then calculate the zero-normalized cross correlation. As it this is not done in Fourier space it is (likely) slower than regular cross correlation. If False: no normalization is performed.subtract_background (
boolor str , optional) – If True or ‘expected_signal’: the expected signal based on the intensity at each location is calculated and subtracted. If ‘minimum_filter’: a minimum filter of two times the kernel size is applied and the resulting image is subtracted. If ‘median_filter’: a median filter of two times the kernel size is applied and the resulting image is subtracted. If ‘expected_signal_rough’: the expected signal is estimated based on the overlap of the images and their average values, the resulting image is subtracted. If False: no background subtraction is performed.plot (
bool) – If True: plots of the synthetic images and the cross-correlation image are shown.axes (
listofmatplotlib.axis.Axis) – Three axes to use for plotting.
Note
Automatic background subtraction is performed on the cross-correlation image. This reduces the difference in intensity between the edges and the center that naturally occur when doing cross-correlation, and it thus helps to find the correct peak.
- density_destination(crop=False, space='destination')#
Destination density estimation from the number of points and the area contained within the convex hull.
- Parameters:
crop (
intorfloat, optional) – If True: the overlap between the source and destination point set is used. If ‘source’: only the source is cropped to the destination point set. If ‘destination’: only the destination is cropped to the source point set. If False: no cropping is applied.
- spacestr, optional
In which coordinate space to obtain the destination density. Either ‘source’ or ‘destination’.
- Returns:
density_source (
float) – Density of the destination dataset
- density_source(crop=False, space='source')#
Source density estimation from the number of points and the area contained within the convex hull.
- Parameters:
crop (
intorfloat, optional) – If True: the overlap between the source and destination point set is used. If ‘source’: only the source is cropped to the destination point set. If ‘destination’: only the destination is cropped to the source point set. If False: no cropping is applied.
- spacestr, optional
In which coordinate space to obtain the source density. Either ‘source’ or ‘destination’.
- Returns:
density_source (
float) – Density of the source dataset
- property destination_area#
- property destination_cropped#
- property destination_cropped_area#
- property destination_cropped_vertices#
- property destination_distance_threshold#
- property destination_to_source#
- property destination_vertices#
- determine_matched_pairs(distance_threshold=None, point_set_name='all')#
Find pairs of source and destination points that closer than the distance threshold and are singly matched, i.e. each source point only has one destination point within the threshold and vice versa.
Sets the matched_pairs attribute.
- Parameters:
distance_threshold (
intorfloat) – Distance threshold for match determination.point_set_name (
str) – If ‘source’ then only the source point should have a single match in the destination point set. the destination point can have multiple matches in the source point set. If ‘destination’ then only the destination point should have a single match in the source point set, the source point can have multiple matches in the destination point set. If ‘all’ then both source and destination should have a single match.
- direct_match(transformation_type=None, **kwargs)#
Find transformation from source to destination points by matching based on the point order
The found transformation is stored in the object transformation parameter.
Note
The number and the order of source points should be equal to the number and the order of destination points.
- Parameters:
transformation_type (
str) – Type of transformation used, either linear or polynomial can be chosen. If not specified the object transformation_type is used.kwargs – Keyword arguments passed to the direct match function.
- distance_matrix(crop=True, space='destination', margin=None, max_distance=None, **kwargs)#
Distance matrix for all point combinations of the source and destination.
- Parameters:
crop (
intorfloat, optional) – If True: the overlap between the source and destination point set is used. If ‘source’: only the source is cropped to the destination point set. If ‘destination’: only the destination is cropped to the source point set. If False: no cropping is applied.space (
str, optional) – In which coordinate space to obtain the distances. Either ‘source’ or ‘destination’.margin (
floatortupleoffloats) – Margins to exclude for the point sets. A tuple should be given in the format (margin_source, margin_destination). If a single margin is passed, then it will be used for both the source and destination.max_distance (
float) – Maximum distance to include in the distance matrix. If given, then a sparse distance matrix will be returned.kwargs – Keyword arguments to pass to the scipy.spatial.cKDTree.distance_matrix or scipy.spatial.cKDTree.sparse_distance_matrix function.
- Returns:
distance_matrix (
MxN numpy.ndarrayorscipy.sparse.spmatrix) – Distance matrix.
- property file_path#
- find_distance_threshold(method='single_match_optimization', **kwargs)#
Find distance optimal distance threshold and automatically sets the destination distance threshold.
- Parameters:
method (
str) –- Method to use for finding the distance threshold. Choose from:
‘single_match_optimization’: Optimizes the number of singly-matched pairs, i.e. the source point having only a single destination point within the distance threshold and the destination point having only a single source point within the distance threshold. See the MatchPoint.single_match_optimization method.
kwargs – Keyword arguments to pass to method.
- fraction_of_destination_matched(crop=False)#
Fraction of the destination points that is matched to a source point
- Parameters:
crop (
boolorstr, optional) – If True: the overlap between the source and destination point set is used. If ‘source’: only the source is cropped to the destination point set. If ‘destination’: only the destination is cropped to the source point set. If False: no cropping is applied.- Returns:
float– Fraction of destination that is matched
- fraction_of_source_matched(crop=False)#
Fraction of the source points that is matched to a destination point
- Parameters:
crop (
boolorstr, optional) – If True: the overlap between the source and destination point set is used. If ‘source’: only the source is cropped to the destination point set. If ‘destination’: only the destination is cropped to the source point set. If False: no cropping is applied.- Returns:
float– Fraction of source that is matched
- geometric_hashing(method='one_by_one', tuple_size=4, maximum_distance_source=None, maximum_distance_destination=None, **kwargs)#
Perform mapping by geometric hashing.
The found transformation is stored in the object’s transformation attribute.
- Parameters:
method (
str) – The method to use: - ‘one_by_one’: tuples are generated, matched and tested sequentially. - ‘abundant_transformations’: All tuples are generated and matched. Transformation parameters are determinedfor matched tuples and the highest density cluster is determined.
tuple_size (
int) – Number of points per tuple.maximum_distance_source (
float) – Maximum distance between the two outermost points in a tuple of the source point set.maximum_distance_destination (
float) – Maximum distance between the two outermost points in a tuple of the destination point set.kwargs – Keyword arguments to pass to the geometric hashing query function.
- get_destination(crop=False, space='destination', margin=None)#
Getter for the destination point set.
- Parameters:
crop (
boolorstr, optional) – If True or ‘destination’, the point set is cropped to the area of the source.space (
str, optional) – In which coordinate space to return the point set. Either ‘source’ or ‘destination’.margin (
floatorint, optional) – Margin used for cropping.
- Returns:
Nx2 numpy.ndaarray– Destination point set
- get_destination_area(crop=False, space='destination')#
Get the area of the destination point set, i.e. within the destination point vertices.
- Parameters:
crop (
boolorstr, optional) – If True: the overlap between the source and destination point set is used. If ‘source’: only the source is cropped to the destination point set. If ‘destination’: only the destination is cropped to the source point set. If False: no cropping is applied.space (
str, optional) – In which coordinate space to return the point set. Either ‘source’ or ‘destination’.
- Returns:
float– Destination area
- get_destination_vertices(crop=False, space='destination', margin=None)#
Getter for vertices of the destination point set.
- Parameters:
crop (
boolorstr, optional) – If True or ‘destination’, the vertices of the overlapping area with the source point set are given.space (
str, optional) – In which coordinate space to return the vertices. Either ‘source’ or ‘destination’.margin (
floatorint, optional) – Margin used for cropping.
- Returns:
Nx2 numpy.ndaarray– Coordinates of the destination vertices
- get_overlap_vertices(space='source')#
Getter for vertices of the overlap between the source and destination point sets.
- Parameters:
space (
str, optional) – In which coordinate space to return the vertices. Either ‘source’ or ‘destination’.- Returns:
Nx2 numpy.ndaarray– Coordinates of the overlap vertices
- get_source(crop=False, space='source', margin=None)#
Getter for the source point set.
- Parameters:
crop (
boolorstr, optional) – If True or ‘source’, the point set is cropped to the area of the destination.space (
str, optional) – In which coordinate space to return the point set. Either ‘source’ or ‘destination’.margin (
floatorint, optional) – Margin used for cropping.
- Returns:
Nx2 numpy.ndaarray– Source point set
- get_source_area(crop=False, space='destination')#
Get the area of the source point set, i.e. within the source point vertices.
- Parameters:
crop (
boolorstr, optional) – If True: the overlap between the source and destination point set is used. If ‘source’: only the source is cropped to the destination point set. If ‘destination’: only the destination is cropped to the source point set. If False: no cropping is applied.space (
str, optional) – In which coordinate space to return the point set. Either ‘source’ or ‘destination’.
- Returns:
float– Source area
- get_source_vertices(crop=False, space='source', margin=None)#
Getter for vertices of the source point set.
- Parameters:
crop (
boolorstr, optional) – If True or ‘source’, the vertices of the overlapping area with the destination point set are given.space (
str, optional) – In which coordinate space to return the vertices. Either ‘source’ or ‘destination’.margin (
floatorint, optional) – Margin used for cropping.
- Returns:
Nx2 numpy.ndaarray– Coordinates of the source vertices
- get_transformation_direction(direction)#
Get inverse parameter based on direction
- Parameters:
direction (
str) –- The direction of the transformation, either ‘<source_name>2<destination_name>’ or
‘<destination_name>2<source_name>’. ‘source2destination’ and ‘destination2source’ can also be used.
- Returns:
inverse (
bool) – Specifier for the use of the forward or inverse transformation.
- get_unit(space)#
Get the unit of the source or destination point set.
- Parameters:
space (
str) – For which coordinate space to obtain the unit. Either ‘source’ or ‘destination’.- Returns:
str– The unit of the point set.
- get_unit_label(space)#
Get the string to add the axis label during plotting. This is either the unit between parentheses, or if no unit is set it is an empty string.
- Parameters:
space (
str) – For which coordinate space to obtain the unit. Either ‘source’ or ‘destination’.- Returns:
str– Unit label
- iterative_closest_point(distance_threshold=None, verbose=True, **kwargs)#
Find transformation from source to destination points using an iterative closest point algorithm
In the iterative closest point algorithm, the two-way nearest neighbours are found and these are used to find the most optimal transformation. Subsequently, the source is transformed according to this transformation. This process is repeated until the changes detected are below a tolerance level.
The iterative closest point algorithm can be used in situations when deviations between the two point sets are relatively small.
The found transformation is stored in the object’s transformation attribute.
Note
The current transformation is used as starting point for the algorithm.
Note
The printed error is based on the points selected for matching.
- Parameters:
distance_threshold (
intorfloat) – Distance threshold applied to select nearest-neighbours in the final round of icp, i.e. nearest-neighbours with distances smaller than distance_threshold.kwargs – Keyword arguments passed to the algorithm.
- kernel_correlation(bounds=((0.97, 1.02), (- 0.05, 0.05), (- 10, 10), (- 10, 10)), sigma=1, crop=False, plot=False, **kwargs)#
Find transformation from source to destination points using an kernel correlation algorithm.
The found transformation is stored in the object’s transformation attribute.
Note
The found kernel correlation value is stored in the objects mapping statistics with key “kernel_correlation_value”.
- Parameters:
bounds (
tupleoftuples) – The bounds for variation of the transformation parameters. The number of tuples passed determines the number of varied parameters. - Two tuples indicates variation of the x and y translation. - Three tuples indicate rotation, x-translation and y-translation. - Four tuples indicate scale, rotation, x-translation and y-translation. - Five tuples indicate scale, rotation, shear, x-translation and y-translation. - Six tuples indicate scale-x, scale-y, rotation, shear, x-translation and y-translation. The rotation parameter is given in radians.sigma (
float) – The standard deviation of the Gaussian kernel used.crop (
boolorstr, optional) – If True: the overlap between the source and destination point set is used. If ‘source’: only the source is cropped to the destination point set. If ‘destination’: only the destination is cropped to the source point set. If False: no cropping is applied.plot (
bool) – Whether to plot the mapping process.kwargs – Keyword arguments passed to the algorithm.
- kernel_correlation_score(sigma=1, crop=False, per_point_pair=False)#
Determine the kernel correlation score for the current transformation.
- Parameters:
sigma (
float) – The standard deviation of the Gaussian kernel used.crop (
boolorstr, optional) – If True: the overlap between the source and destination point set is used. If ‘source’: only the source is cropped to the destination point set. If ‘destination’: only the destination is cropped to the source point set. If False: no cropping is applied.per_point_pair (
bool) – If True the kernel correlation score is returned for each point pair in a 2D matrix. If False a summed kernel correlation score is returned.
- Returns:
floatorNxM numpy.ndarray– Kernel correlation score
- classmethod load(filepath)#
Load a saved MatchPoint object
- Parameters:
filepath (
strorpathlib2.Path) – Filepath to the saved object.- Returns:
mapping (
MatchPoint) – Saved MatchPoint object.
- nearest_neighbour_match(distance_threshold=None, transformation_type=None, **kwargs)#
Find transformation from source to destination points by matching nearest neighbours.
Two-way nearest neighbours are detected, i.e. the source point should be the nearest neighbour of the destination point and vice versa. Only nearest neighbours closer than the distance threshold are used to find the transformation.
The found transformation is stored in the object transformation parameter.
Note
The current transformation is used as starting point for the algorithm.
Note
The printed error is based on the points selected for matching.
- Parameters:
distance_threshold (
float) – Distance threshold for nearest neighbour match in destination space. Only nearest neighbours with a distance smaller than the distance threshold are used.transformation_type (
str) – Type of transformation used. For options see MatchPoint.transformation_type. If not specified the object transformation_type is used.kwargs – Keyword arguments passed to the nearest-neighbour match function.
- property number_of_destination_points#
- property number_of_matched_points#
- number_of_matches_for_source_and_destination(distance_threshold=None, matches_per_point=[0, 1], crop=True)#
Gives the number of source and destination points that respectively have a specified number of matches with the destination and source point sets.
- Parameters:
distance_threshold (
int,float,listornumpy.ndarray) – Distance threshold(s) to determine the number of matches for. If None (default) then the destination_distance_threshold attribute is used.matches_per_point (
intorlistofint) – Number of matches to reportcrop (
boolorstr, optional) – If True: the overlap between the source and destination point set is used. If ‘source’: only the source is cropped to the destination point set. If ‘destination’: only the destination is cropped to the source point set. If False: no cropping is applied.
- Returns:
xarray.DataArray– Number of source or destination points with specific distance threshold
- number_of_single_matches_for_radii(distance_thresholds)#
The number of singly-matched pairs for the provided distance thresholds.
Here singly-matched pairs are defined as the source point having only a single destination point within the distance threshold and the destination point having only a single source point within the distance threshold.
- Parameters:
distance_thresholds (
1D numpy.ndaarray) – Distance thresholds to test.- Returns:
1D numpy.ndaarray– Number of singly-matched points for each distance threshold.
- property number_of_source_points#
- pair_coordinates(point_set_name='destination', space='destination')#
Get the coordinates of the paired source or destination points.
- Parameters:
point_set_name (
str) – Name from the point set to use the coordinates from. Either ‘source’ or ‘destination’ (default).space (
str, optional) – In which coordinate space to return the coordinates. Either ‘source’ or ‘destination’ (default).
- Returns:
Nx2 numpy.ndaarray– Coordinates of paired points
- pair_distances(space='destination', show=False, **kwargs)#
Distances between the paired source and destination points.
- Parameters:
space (
str, optional) – In which coordinate space to return the coordinates. Either ‘source’ or ‘destination’ (default).show (
bool) – If True, show a histogram of the distances.kwargs – Keyword arguments passed to matplotlib.pyplot.histogram.
- Returns:
1D numpy.ndaarray– Distances between paired points.
- perform_mapping(method=None, **kwargs)#
Find transformation from source to destination points using one of the mapping methods
The starting point for the mapping is the initial_transformation attribute.
- Parameters:
method (
str) – Mapping method, if not specified the object method is used.kwargs – Keyword arguments passed to mapping methods.
- property rotation#
- save(save_path=None, filetype='nc')#
Save the current mapping in a file, so that it can be opened later.
- Parameters:
filepath (
strorpathlib.Path) – Path to file (including filename)filetype (
str) – Choose classic to export a .coeff file for a linear transformation Choose yml to export all object attributes in a yml text file
- property scale#
- set_correlation_peak_coordinates(correlation_peak_coordinates)#
Manually set the peak coordinates after cross-cross correlation.
Note
This function can only be used after cross-correlation is run.
- Parameters:
correlation_peak_coordinates (
list,tupleor1D numpy.ndarray) – Pixel coordinates of the manually found peak in the cross-correlation image.
- property shear#
- show(axis=None, show_source=False, show_destination=False, show_transformed_coordinates=True, show_pairs=True, crop=False, inverse=False, source_colour='forestgreen', destination_colour='r', pair_colour='b', use_distance_threshold=False, save=False, save_path=None, show_legend=False, return_plot=False)#
Show the mapping.
Show the source and destination points in a scatter plot.
- Parameters:
axis (
matplotlib.axis.Axis) – The axis to use for plotting. If no axis is given a new figure and axis are created.show_source (
bool) – If True: the original source point set is shown.show_destination (
bool) – If True: the original destination point set is shown.show_transformed_coordinates (
bool) – If True: the transformed point set is shown. If ‘inverse’ is set to False, this is the transformed source point set. If ‘inverse’ is set to True, this is the transformed destination point set.show_pairs (
bool) – If True: the paired points are indicated in a different colour.crop (
boolorstr) – If True: the overlap between the source and destination point set is used. If ‘source’: only the source is cropped to the destination point set. If ‘destination’: only the destination is cropped to the source point set. If False: no cropping is applied.inverse (
bool) – Indicates the direction of the transformation to use. If False: the source is transformed to destination space. If True: the destination is transformed to the source space.source_colour (
str) – Colour used for the source points.destination_colour (
str) – Colour used for the destination points.pair_colour (
str) – Colour used to indicate paired points.use_distance_threshold (
bool) – If True: the open circles of the transformed point set will have the size of the source or destination distance threshold. Note: using this option slows down plotting so it is not recommended for large datasets.save (
bool) – If True: the figure is saved in the save path.save_path (
strorpathlib2.Path) – Folderpath to save the figure to. If no path is given, the object’s save_path is used. For the name of the file, the object’s name attribute is used.show_legend (
bool) – If True: the legend is shown.return_plot (
bool) – If True: the figure and axis are returned by the function.
- Returns:
figure (
matplotlib.figure.Figure) – Figure of the plotaxis (
matplotlib.axes.Axes) – Axis of the plot
- show_destination(**kwargs)#
Plot the destination point set.
- Parameters:
kwargs – Keyword arguments to pass to the show function. Keyword arguments starting with “show” should not be used.
- Returns:
figure (
matplotlib.figure.Figure) – Figure of the plotaxis (
matplotlib.axes.Axes) – Axis of the plot
- show_mapping_transformation(*args, **kwargs)#
Show the mapping. Identical to MatchPoint.show().
- show_outline(inverse=False, source_colour='forestgreen', destination_colour='r', axis=None)#
Show the outline or border of the point sets.
- Parameters:
inverse (
bool) – Indicates the direction of the transformation to use. If False: the source is transformed to destination space. If True: the destination is transformed to the source space.source_colour (
str) – Colour used for the source points.destination_colour (
str) – Colour used for the destination points.axis (
matplotlib.axis.Axis) – The axis to use for plotting. If no axis is given a new figure and axis are created.
- Returns:
figure (
matplotlib.figure.Figure) – Figure of the plotaxis (
matplotlib.axes.Axes) – Axis of the plot
- show_source(**kwargs)#
Plot the source point set.
- Parameters:
kwargs – Keyword arguments to pass to the show function. Keyword arguments starting with “show” should not be used.
- Returns:
figure (
matplotlib.figure.Figure) – Figure of the plotaxis (
matplotlib.axes.Axes) – Axis of the plot
- classmethod simulate(number_of_points=200, transformation=None, bounds=[[0, 0], [256, 512]], crop_bounds=(None, None), fraction_missing=(0.1, 0.1), error_sigma=(0.5, 0.5), shuffle=True, seed=10532, show_correct=True)#
Simulate a point set with a specific transformation and return as a MatchPoint object. It generates an original point set of which the source and destination point sets are subsets.
- Parameters:
number_of_points (
int) – Number of points in the original point set to simulate, the source and destination point sets are drawn from the original point set.transformation (
skimage.transform._geometric.GeometricTransform) – Transformation to be used between the source and destination point sets. If None, a preset transformation will be used: SimilarityTransform(translation=[256, 10], rotation=1/360*2*np.pi, scale=[0.98, 0.98]).bounds (
2x2 numpy.ndarrayorlist) – Bounds of the original point set. Structured like coordinates, i.e. columns are x and y dimensions, rows are minimum and maximum values. [[x_min, y_min],[x_max, y_max]]crop_bounds (
tupleof2x2 numpy.ndarrayortupleof2x2 list, optional) – Bounds to be used for cropping the overall dataset into the source and destination point set (before the transformation is applied).fraction_missing (
tuple(float,float)) – Fraction of points that is removed from the original point set to obtain the source and destination point sets.error_sigma (
tuple(float,float)) – Standard deviation of the Gaussian error applied to the original point set to obtain the source and destination point sets.shuffle (
bool) – If True (default) then the points in the destination point set will be shuffled. If False the order of the destination points in the source and destination will be identical.seed (
int) – Seed used for random number generator.show_correct (
bool) – If True show the generated dataset with the correct transformation.
- Returns:
mapping (
MatchPoint) – MatchPoint object with the simulated source and destination point sets. While the “transformation” attribute is set with a unit transformation, mapping has an additional attribute “transformation_correct” containing the correct transformation. The returned mapping also has a “show_correct_mapping_transformation” method, to visualize the correct transformation.
- single_match_optimization(maximum_radius=20, number_of_steps=100, plot=True)#
Find the distance threshold with the highest number of singly matched pairs.
Test thresholds between 0 and maximum_radius. Destination_distance_threshold is automatically set to the found value.
- Parameters:
maximum_radius (
float) – Maximum distance threshold to test.number_of_steps (
int) – Number of steps on the intervalplot (
bool) – If True, a histogram of the number of pairs per distance threshold will be plotted
- property source_area#
- property source_cropped#
- property source_cropped_area#
- property source_cropped_vertices#
- property source_distance_threshold#
- property source_in_destination_area#
- property source_to_destination#
- property source_vertices#
- transform_coordinates(coordinates, inverse=False, direction=None)#
Transform coordinates using the object’s transformation.
- Parameters:
coordinates (
Nx2 numpy.ndarray) – Coordinates to be transformedinverse (
bool) – If True: the inverse transformation will be used (i.e. from destination to source)direction (
str) – Another way of specifying the direction of the transformation, choose ‘source2destination’, ‘destination2source’ or use the object’s source and destination names instead of ‘source’ and ‘destination’.
- Returns:
Nx2 numpy.ndarray– Transformed coordinates
- transform_image(image, inverse=False, direction=None)#
Transform an image using the objects transformation.
- Parameters:
image (
NxM numpy.ndarray) – Image to be transformed.inverse (
bool) – If True: the inverse transformation will be used (i.e. from destination to source)direction (
str) – Another way of specifying the direction of the transformation, choose ‘source2destination’, ‘destination2source’ or use the object’s source and destination names instead of ‘source’ and ‘destination’.
- Returns:
NxM numpy.ndarray– Transformed image
- property transformation#
- property transformation_inverse#
- transformation_is_similar_to_correct_transformation(**kwargs)#
- property transformation_type#
- transformation_types = {'affine': <class 'skimage.transform._geometric.AffineTransform'>, 'linear': <class 'skimage.transform._geometric.AffineTransform'>, 'nonlinear': <class 'matchpoint.polywarp.PolywarpTransform'>, 'polynomial': <class 'matchpoint.polynomial.PolynomialTransform'>, 'similarity': <class 'skimage.transform._geometric.SimilarityTransform'>}#
- property translation#