Object matching module¶
-
OpFlowLab.functions.object_matching.calculate_contour(label_image)[source]¶ Calculates the contour of the object
- Parameters
- label_imagendarray
Local image of each object
- Returns
- contourarray_like
List of points describing the contour of the object
-
OpFlowLab.functions.object_matching.calculate_distance(x, y, circular=True)[source]¶ Calculates distances between consecutive points in the list
- Parameters
- x, yarray_like
List of x, y position to calculate the Euclidean distances from
- circularbool, optional
Determine if the distance between the last and first point should be calculated
- Returns
- distarray_like
List of distances between consecutive points
-
OpFlowLab.functions.object_matching.calculate_matched_velocities(initial_properties, target_properties, reverse_pair_list, forward_index, forward_unique, forward_bincount, reverse_unique, reverse_bincount, diff_search, matched_flow_x, matched_flow_y, selected_initial_mask, selected_target_mask, label_pos=0)[source]¶ Calculates the velocities between matched pairs
- Parameters
- initial_propertiesarray_like
List of properties for each object in the initial image
- target_propertiesarray_like
List of properties for each object in the target image
- reverse_pair_listarray_like
List of pairs between the target image and the warped initial image
- forward_indexarray_like
Indices of the first occurrence of the pairs
- forward_uniquearray_like
Label of the corresponding pair
- forward_bincountarray_like
Number of times that the pair is returned
- reverse_uniquearray_like
Label of the corresponding pair in the reverse time direction
- reverse_bincountarray_like
Number of times that the pair is returned in the reverse time direction
- diff_searchint
Difference between the largest value of the labelled image and the length of the target property. Used to reduce the number of items used in the search to find a match
- matched_flow_xndarray
Calculated velocities in the x direction
- matched_flow_yndarray
Calculated velocities in the y direction
- selected_initial_maskarray_like
Mask to track which objects in the initial image have been paired
- selected_target_maskarray_like
Mask to track which objects in the target image have been paired
- label_posint, optional
Index indicating the position of the labels inside properties
- Returns
- matched_flow_xndarray
Calculated velocities in the x direction
- matched_flow_yndarray
Calculated velocities in the y direction
- selected_initial_maskarray_like
Mask to track which objects in the initial image have been paired
- selected_target_maskarray_like
Mask to track which objects in the target image have been paired
-
OpFlowLab.functions.object_matching.estimate_affine(pt1_perimeter, pt2_perimeter)[source]¶ Calculates the affine matrix needed to transform the points in the perimeter of the first object to the second object
- Parameters
- pt1_perimeterarray_like
List of coordinates on the perimeter of the first object
- pt2_perimeterfloat
List of coordinates on the perimeter of the second object
- Returns
- solutionarray_like
Affine matrix used to describe the transformation between the two sets of points
-
OpFlowLab.functions.object_matching.fast_distance_function(centroids, pos)[source]¶ Calculates pairwise Euclidean distances between two array of coordinates
- Parameters
- centroidsarray_like
List of centroid coordinates of shape (n,2)
- posarray_like
List of position coordinates of shape (m,2)
- Returns
- darray_like
Pairwise distance between coordinates
-
OpFlowLab.functions.object_matching.get_pairs(properties, remapped_target_image, coord_pos=5)[source]¶ Identifies potential pairs from a warped image based on the centroid positions
- Parameters
- propertiesarray_like
List of properties for each object in the image
- remapped_target_imagendarray
Remapped image that has been warped with a velocity field
- coord_posint, optional
Index indicating the position of the coordinates inside properties
- Returns
- forward_pair_listarray_like
Array containing the list of pairs
-
OpFlowLab.functions.object_matching.obtain_perimeter_points(local_centroid, orientation, major_axis, contour)[source]¶ Obtain points on the object perimeter starting from the top most point on the long axis of the fitted ellipse
- Parameters
- local_centroidarray_like
Local centroid position of the object
- orientationfloat
Orientation of the object
- major_axisfloat
Length of the major axis of the object
- contourarray_like
List of points on the contour of the object
- Returns
- pt_listarray_like
Sorted coordinates of the perimeter points starting from the top most point on the long axis
-
OpFlowLab.functions.object_matching.remove_items(properties, mask)[source]¶ Removes objects from the list of properties based on a binary mask
- Parameters
- propertiesarray_like
List of object properties
- maskarray_like
Binary mask indicating which objects should be removed
- Returns
- outputarray_like
Shortened list of properties with objects removed based on mask
-
OpFlowLab.functions.object_matching.reslice_positions(x, y, num_points=21)[source]¶ Interpolates a list of x, y positions to a list of evenly spaced points
- Parameters
- x, yarray_like
List of x, y position to interpolate from
- num_pointsint, optional
Number of points with which to generate from the list
- Returns
- output_x, output_yarray_like
List of interpolated points
-
OpFlowLab.functions.object_matching.single_object_velocity(object1_properties, object2_properties, local_centroid_pos=1, centroid_pos=2, orientation_pos=3, major_axis_pos=4, coords_pos=5, contour_pos=6)[source]¶ Calculated the velocity of the object between two time frames
- Parameters
- object1_propertiesarray_like
List of properties for the object in time frame 1
- object2_propertiesarray_like
List of properties for the object in time frame 2
- local_centroid_posint, optional
Index indicating the position of the local centroid potision inside properties
- centroid_posint, optional
Index indicating the position of the centroid position inside properties
- orientation_posint, optional
Index indicating the position of the orientation inside properties
- major_axis_posint, optional
Index indicating the position of the major axis length inside properties
- coords_posint, optional
Index indicating the position of the coordinates inside properties
- contour_posint, optional
Index indicating the position of the contour inside properties
- Returns
- pt1_coordsarray_like
Coordinates of all the pixels in the object
- output_velocityarray_like
Velocity for each pixel in the object