CLIJ2

Logo

GPU accelerated image processing for everyone

CLIJ2 home

countTouchingNeighbors

Takes a touch matrix as input and delivers a vector with number of touching neighbors per label as a vector.

Category: Measurements

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

countTouchingNeighbors often follows after

countTouchingNeighbors is often followed by

Usage in ImageJ macro

Ext.CLIJ2_countTouchingNeighbors(Image touch_matrix, Image touching_neighbors_count_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 touch_matrix = clij2.push(touch_matrixImagePlus);
touching_neighbors_count_destination = clij2.create(touch_matrix);
// Execute operation on GPU
clij2.countTouchingNeighbors(touch_matrix, touching_neighbors_count_destination);
// show result
touching_neighbors_count_destinationImagePlus = clij2.pull(touching_neighbors_count_destination);
touching_neighbors_count_destinationImagePlus.show();

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

% get input parameters
touch_matrix = clij2.pushMat(touch_matrix_matrix);
touching_neighbors_count_destination = clij2.create(touch_matrix);
% Execute operation on GPU
clij2.countTouchingNeighbors(touch_matrix, touching_neighbors_count_destination);
% show result
touching_neighbors_count_destination = clij2.pullMat(touching_neighbors_count_destination)

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

clij2 = CLICY.getInstance();

// get input parameters
touch_matrix_sequence = getSequence();
touch_matrix = clij2.pushSequence(touch_matrix_sequence);
touching_neighbors_count_destination = clij2.create(touch_matrix);
// Execute operation on GPU
clij2.countTouchingNeighbors(touch_matrix, touching_neighbors_count_destination);
// show result
touching_neighbors_count_destination_sequence = clij2.pullSequence(touching_neighbors_count_destination)
Icy.addSequence(touching_neighbors_count_destination_sequence);
// cleanup memory on GPU
clij2.release(touch_matrix);
clij2.release(touching_neighbors_count_destination);
clEsperanto Python (experimental)
import pyclesperanto_prototype as cle

cle.count_touching_neighbors(touch_matrix, touching_neighbors_count_destination)

Example notebooks

spots_pointlists_matrices_tables
mesh_between_touching_neighbors.ipynb
tissue_neighborhood_quantification.ipynb

Example scripts

division_visualisation.ijm
spots_pointlists_matrices_tables.ijm

Back to CLIJ2 reference Back to CLIJ2 documentation

Imprint