CLIJ2

Logo

GPU accelerated image processing for everyone

CLIJ2 home

generateDistanceMatrix

Computes the distance between all point coordinates given in two point lists.

Takes two images containing pointlists (dimensionality n * d, n: number of points and d: dimensionality) and builds up a matrix containing the distances between these points.

Convention: Given two point lists with dimensionality n * d and m * d, the distance matrix will be of size(n + 1) * (m + 1). The first row and column contain zeros. They represent the distance of the objects to a theoretical background object. In that way, distance matrices are of the same size as touch matrices (see generateTouchMatrix). Thus, one can threshold a distance matrix to generate a touch matrix out of it for drawing meshes.

Categories: Graphs, Measurements

generateDistanceMatrix often follows after

generateDistanceMatrix is often followed by

Usage in ImageJ macro

Ext.CLIJ2_generateDistanceMatrix(Image coordinate_list1, Image coordinate_list2, Image distance_matrix_destination);

Usage in object oriented programming languages

Java
// init CLIJ and GPU
import net.haesleinhuepf.clij2.CLIJ2;
import net.haesleinhuepf.clij.clearcl.ClearCLBuffer;
CLIJ2 clij2 = CLIJ2.getInstance();

// get input parameters
ClearCLBuffer coordinate_list1 = clij2.push(coordinate_list1ImagePlus);
ClearCLBuffer coordinate_list2 = clij2.push(coordinate_list2ImagePlus);
distance_matrix_destination = clij2.create(coordinate_list1);
// Execute operation on GPU
clij2.generateDistanceMatrix(coordinate_list1, coordinate_list2, distance_matrix_destination);
// show result
distance_matrix_destinationImagePlus = clij2.pull(distance_matrix_destination);
distance_matrix_destinationImagePlus.show();

// cleanup memory on GPU
clij2.release(coordinate_list1);
clij2.release(coordinate_list2);
clij2.release(distance_matrix_destination);
Matlab
% init CLIJ and GPU
clij2 = init_clatlab();

% get input parameters
coordinate_list1 = clij2.pushMat(coordinate_list1_matrix);
coordinate_list2 = clij2.pushMat(coordinate_list2_matrix);
distance_matrix_destination = clij2.create(coordinate_list1);
% Execute operation on GPU
clij2.generateDistanceMatrix(coordinate_list1, coordinate_list2, distance_matrix_destination);
% show result
distance_matrix_destination = clij2.pullMat(distance_matrix_destination)

% cleanup memory on GPU
clij2.release(coordinate_list1);
clij2.release(coordinate_list2);
clij2.release(distance_matrix_destination);
Icy JavaScript
// init CLIJ and GPU
importClass(net.haesleinhuepf.clicy.CLICY);
importClass(Packages.icy.main.Icy);

clij2 = CLICY.getInstance();

// get input parameters
coordinate_list1_sequence = getSequence();
coordinate_list1 = clij2.pushSequence(coordinate_list1_sequence);
coordinate_list2_sequence = getSequence();
coordinate_list2 = clij2.pushSequence(coordinate_list2_sequence);
distance_matrix_destination = clij2.create(coordinate_list1);
// Execute operation on GPU
clij2.generateDistanceMatrix(coordinate_list1, coordinate_list2, distance_matrix_destination);
// show result
distance_matrix_destination_sequence = clij2.pullSequence(distance_matrix_destination)
Icy.addSequence(distance_matrix_destination_sequence);
// cleanup memory on GPU
clij2.release(coordinate_list1);
clij2.release(coordinate_list2);
clij2.release(distance_matrix_destination);
clEsperanto Python (experimental)
import pyclesperanto_prototype as cle

cle.generate_distance_matrix(coordinate_list1, coordinate_list2, distance_matrix_destination)

Example notebooks

spots_pointlists_matrices_tables
tables
tribolium_morphometry

Example scripts

mesh_closest_points.ijm
spots_pointlists_matrices_tables.ijm
spot_distance_measurement.ijm
tables.ijm
tribolium_morphometry.ijm
mesh_closest_points.py

Back to CLIJ2 reference Back to CLIJ2 documentation

Imprint