CLIJ2

Logo

GPU accelerated image processing for everyone

CLIJ2 home

labelToMask

Masks a single label in a label map.

Sets all pixels in the target image to 1, where the given label index was present in the label map. Other pixels are set to 0.

Categories: Labels, Binary

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

Usage in ImageJ macro

Ext.CLIJ2_labelToMask(Image label_map_source, Image mask_destination, Number label_index);

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_source = clij2.push(label_map_sourceImagePlus);
mask_destination = clij2.create(label_map_source);
float label_index = 1.0;
// Execute operation on GPU
clij2.labelToMask(label_map_source, mask_destination, label_index);
// show result
mask_destinationImagePlus = clij2.pull(mask_destination);
mask_destinationImagePlus.show();

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

% get input parameters
label_map_source = clij2.pushMat(label_map_source_matrix);
mask_destination = clij2.create(label_map_source);
label_index = 1.0;
% Execute operation on GPU
clij2.labelToMask(label_map_source, mask_destination, label_index);
% show result
mask_destination = clij2.pullMat(mask_destination)

% cleanup memory on GPU
clij2.release(label_map_source);
clij2.release(mask_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_source_sequence = getSequence();
label_map_source = clij2.pushSequence(label_map_source_sequence);
mask_destination = clij2.create(label_map_source);
label_index = 1.0;
// Execute operation on GPU
clij2.labelToMask(label_map_source, mask_destination, label_index);
// show result
mask_destination_sequence = clij2.pullSequence(mask_destination)
Icy.addSequence(mask_destination_sequence);
// cleanup memory on GPU
clij2.release(label_map_source);
clij2.release(mask_destination);

Example notebooks

working_with_rois

Example scripts

boundingBoxes.ijm
center_of_mass.ijm
working_with_rois.ijm

Back to CLIJ2 reference Back to CLIJ2 documentation

Imprint