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.

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 Java

clij2.generateTouchMatrix(label_map, touch_matrix_destination);
// 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);

Usage in Matlab

clij2.generateTouchMatrix(label_map, touch_matrix_destination);
% 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);

Usage in Icy

clij2.generateTouchMatrix(label_map, touch_matrix_destination);
// 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);

Example notebooks

filtering_in_graphs
mean_of_touching_neighbors
neighbors_of_neighbors
spots_pointlists_matrices_tables
superpixel_segmentation
tribolium_morphometry

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