CLIJ2

Logo

GPU accelerated image processing for everyone

CLIJ2 home

generateTouchMatrix

Takes a labelmap with n labels and generates a (n+1)*(n+1) matrix where all pixels are set to 0 exept those where labels are touching.

Only half of the matrix is filled (with x < y). For example, if labels 3 and 4 are touching then the pixel (3,4) in the matrix will be set to 1. The touch matrix is a representation of a region adjacency graph

Categories: Graphs, Measurements, Labels

Availability: Available in Fiji by activating the update sites clij and clij2. This function is part of clij2_-2.5.0.1.jar.

generateTouchMatrix often follows after

generateTouchMatrix is often followed by

Usage in ImageJ macro

Ext.CLIJ2_generateTouchMatrix(Image label_map, Image touch_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 label_map = clij2.push(label_mapImagePlus);
touch_matrix_destination = clij2.create(label_map);
// Execute operation on GPU
clij2.generateTouchMatrix(label_map, touch_matrix_destination);
// show result
touch_matrix_destinationImagePlus = clij2.pull(touch_matrix_destination);
touch_matrix_destinationImagePlus.show();

// cleanup memory on GPU
clij2.release(label_map);
clij2.release(touch_matrix_destination);
Matlab
% init CLIJ and GPU
clij2 = init_clatlab();

% get input parameters
label_map = clij2.pushMat(label_map_matrix);
touch_matrix_destination = clij2.create(label_map);
% Execute operation on GPU
clij2.generateTouchMatrix(label_map, touch_matrix_destination);
% show result
touch_matrix_destination = clij2.pullMat(touch_matrix_destination)

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

clij2 = CLICY.getInstance();

// get input parameters
label_map_sequence = getSequence();
label_map = clij2.pushSequence(label_map_sequence);
touch_matrix_destination = clij2.create(label_map);
// Execute operation on GPU
clij2.generateTouchMatrix(label_map, touch_matrix_destination);
// show result
touch_matrix_destination_sequence = clij2.pullSequence(touch_matrix_destination)
Icy.addSequence(touch_matrix_destination_sequence);
// cleanup memory on GPU
clij2.release(label_map);
clij2.release(touch_matrix_destination);
clEsperanto Python (experimental)
import pyclesperanto_prototype as cle

cle.generate_touch_matrix(label_map, touch_matrix_destination)

Example notebooks

filtering_in_graphs
mean_of_touching_neighbors
neighbors_of_neighbors
spots_pointlists_matrices_tables
superpixel_segmentation
tribolium_morphometry
spots_pointlists_matrices_tables.ipynb
mesh_between_touching_neighbors.ipynb
mesh_with_distances.ipynb
neighbors_of_neighbors.ipynb
shape_descriptors_based_on_neighborhood_graphs.ipynb
tissue_neighborhood_quantification.ipynb
tribolium_morphometry.ipynb

Example scripts

division_visualisation.ijm
filtering_in_graphs.ijm
large_matrices.ijm
mean_of_touching_neighbors.ijm
meshTouchingNeighbors.ijm
neighbors_of_neighbors.ijm
rotating_sphere.ijm
spots_pointlists_matrices_tables.ijm
superpixel_segmentation.ijm
tribolium_morphometry.ijm
mesh_close_points.m

Back to CLIJ2 reference Back to CLIJ2 documentation

Imprint