Skip to content

LAPLinker

Jian Tay edited this page Jun 15, 2021 · 3 revisions

LAPLinker (Generated 09-Mar-2020 14:18:31)

Class Properties

Solver

Solver - Algorithm to solve assignment problem

Get Access: public Set Access: public

LinkedBy

LinkedBy - Data fieldname used to link cells

Get Access: public Set Access: public

LinkCostMetric

LinkCostMetric - Metric to compute linking costs

Get Access: public Set Access: public

LinkScoreRange

LinkScoreRange - Valid linking score range

Get Access: public Set Access: public

MaxTrackAge

MaxTrackAge - How many frames a track can go before tracking stops

Get Access: public Set Access: public

TrackDivision

TrackDivision - If true, division events will be tracked

Get Access: public Set Access: public

DivisionParameter

DivisionParameter - Data fieldname used to track division

Get Access: public Set Access: public

DivisionScoreMetric

DivisionScoreMetric - Metric to compute division likelihood

Get Access: public Set Access: public

DivisionScoreRange

DivisionScoreRange - Valid division score range

Get Access: public Set Access: public

MinFramesBetweenDiv

MinFramesBetweenDiv - Minimum number of frames between division events

Get Access: public Set Access: public

metadata

metadata - Struct for user to store metadata

Get Access: public Set Access: private

tracks

Data structure for track data

Get Access: public Set Access: private

activeTrackIDs

LAPLinker/activeTrackIDs is a property.

Get Access: public Set Access: private

NumTracks

NumTracks - Number of tracks

Get Access: public Set Access: public

Class Methods

getTrack

LAPLinker/getTrack is a function. track = getTrack(obj, trackID)

updateTrack

UPDATETRACK Modify track data

OBJ = UPDATETRACK(OBJ, TRACK, FRAME, DATA) inserts data into the tracks struct. The insertion is sorted, i.e. the data is inserted such that the track's Frame field is sequentially increasing.

This function is primarily used during track assignment to add data to existing tracks. However, the function can also be used if manual correction of specific tracks/frames are necessary.

Examples: %Update the 'Centroid' field in frame 3 of track 5 OBJ = UPDATETRACK(OBJ, 5, 3, struct('Centroid', [10, 3]));

startTrack

OBJ = NEWTRACK(OBJ, FIRSTFRAME, DATA) creates a new track entry in the data structure. FIRSTFRAME should be the frame number of the first frame for the track.

DATA should be a struct with fields containing the measured properties for the track (e.g. similar to the output of regionprops). If DATA is a struct array, the number of tracks created will be the same as the number of array elements.

The resulting track data is stored as a cell array in the 'tracks' property of the object. Tracks will always contain the fields 'Frame', 'MotherInd', and 'DaughterInd'. New tracks cannot have 'Frame' as a data property.

importsettings

IMPORTSETTINGS Import settings from text file

IMPORTSETTINGS(OBJ) will create a dialog box allowing the user to select which settings file to read. The settings of the object are the object properties, except for track data and file metadata.

As an alternative, IMPORTSETTINGS(OBJ, FILE) will read the settings from a specified FILE.

See also: LAPLinker/EXPORTSETTINGS

exportsettings

EXPORTSETTINGS Write tracking properties to text file

EXPORTSETTINGS(OBJ) will create a dialog box allowing the user to select where to save the output file. The settings of the object are the object properties, except for track data and file metadata.

As an alternative, EXPORTSETTINGS(OBJ, FILE) will write the settings to the specified FILE.

See also: LAPLinker/importsettings

updateMetadata

UPDATEMETADATA Update the metadata struct

OBJ = UPDATEMETADATA(OBJ, PARAM1, VALUE1, ... PARAMN, VALUEN) updates the 'metadata' property. PARAM1...N should be strings containing the name of the metadata field. The corresponding field values should be provided in VALUE1...N. There should be the same number of values as parameter names.

The intent is of this function is to allow file specific metadata to be saved (e.g. filename, pixel size, image size etc.).

Note: Property names must be allowed by MATLAB, i.e. must start with a letter and contain no special characters apart from underscore.

splitTrack

Split the tracks

assignToTrack

ASSIGNTOTRACK Assign data to tracks

OBJ = ASSIGNTOTRACK(OBJ, FRAME, DATA) assigns new data to tracks using the linear assignment approach. FRAME should be the current frame number. DATA is a struct array, with each element being the data from a single new detection. The properties being tracked should be a field in the struct. An example of the appropriate structure to use is the output of 'regionprops'. If no tracks currently exist (i.e. this is the first frame), the function will create new tracks.

The cost of assignments vs creating new tracks are computed using the data specified in the property 'LinkedBy'. Currently, only two metrics are supported: 'euclidean' - Distance between new detection and last known position of objects (i.e. using 'Centroid') 'pxintersect' - Number of overlapping pixels (the input data should have 'PixelIdxList')

The algorithm specified in the 'Solver' property of the object is used to perform the assignment. Currently, the two solvers built into this software are:

  'lapjv' - Jonker-Volgenant assignment
  'munkres' - Munkres/Hungarian algorithm

You can use your own solver by specifying the name of the function in the 'Solver' property. Your assignment function must take only a single input, the cost matrix, and return a vector that contains the assignment of a row to a column.

See also: regionprops

LAPLinker

Constructor function

lapjv

LAPJV Jonker-Volgenant Algorithm for Linear Assignment Problem.

[ROWSOL,COST,v,u,rMat] = LAPJV(COSTMAT, resolution) returns the optimal column indices, ROWSOL, assigned to row in solution, and the minimum COST based on the assignment problem represented by the COSTMAT, where the (i,j)th element represents the cost to assign the jth job to the ith worker. The second optional input can be used to define data resolution to accelerate speed. Other output arguments are: v: dual variables, column reduction numbers. u: dual variables, row reduction numbers. rMat: the reduced cost matrix.

For a rectangular (nonsquare) costMat, rowsol is the index vector of the larger dimension assigned to the smaller dimension.

[ROWSOL,COST,v,u,rMat] = LAPJV(COSTMAT,resolution) accepts the second input argument as the minimum resolution to differentiate costs between assignments. The default is eps.

Known problems: The original algorithm was developed for integer costs. When it is used for real (floating point) costs, sometime the algorithm will take an extreamly long time. In this case, using a reasonable large resolution as the second arguments can significantly increase the solution speed.

version 3.0 by Yi Cao at Cranfield University on 10th April 2013

This Matlab version is developed based on the orginal C++ version coded by Roy Jonker @ MagicLogic Optimization Inc on 4 September 1996. Reference: R. Jonker and A. Volgenant, "A shortest augmenting path algorithm for dense and spare linear assignment problems", Computing, Vol. 38, pp. 325-340, 1987.

Examples Example 1: a 5 x 5 example {

munkres

MUNKRES Munkres (Hungarian) linear assignment

[I, C] = MUNKRES(M) returns the column indices I assigned to each row, and the minimum cost C based on the assignment. The cost of the assignments are given in matrix M, with workers along the rows and tasks along the columns. The matrix optimizes the assignment by minimizing the total cost.

The code can deal with partial assignments, i.e. where M is not a square matrix. Unassigned rows (workers) will be given a value of 0 in the output I. [I, C, U] = MUNKRES(M) will give the index of unassigned columns (tasks) in vector U.

The algorithm attempts to speed up the process in the case where values of a row or column are all Inf (i.e. impossible link). In that case, the row or column is excluded from the assignment process; these will be automatically unassigned in the result.

This code is based on the algorithm described at: http://csclab.murraystate.edu/bob.pilgrim/445/munkres.html

computecost

COMPUTECOST Compute the cost to link tracks

COMPUTECOST(TRACK, DET, METHOD) computes the cost of linking new detections DET to existing tracks TRACK. newData must be a cell. Parameters as columns, observations as rows

The current METHODs supported are: 'euclidean' - sqrt(sum((A - D).^2)) 'pxintersect' - Number of overlapping pixels (the input data should have 'PixelIdxList')

empty

Returns an empty object array of the given size