CLIJ2

Logo

GPU accelerated image processing for everyone

CLIJ2 home

Image statistics

Authors: Robert Haase, Daniela Vorkel, April 2020

Source

This macro shows how to retrieve basic statistics from images.



// get test data
run("Blobs (25K)");
run("Invert LUT");
input = getTitle();

blobs.gif

Initialize GPU

and push image data to GPU memory:

run("CLIJ2 Macro Extensions", "cl_device=");
Ext.CLIJ2_clear();

// push data to GPU
Ext.CLIJ2_push(input);

// clean up ImageJ
run("Close All");

Image properties

In order to read out properties like image size, we get all dimensions by one call. CLIJ does not take pixel or voxel into account, because there are no physical units defined in CLIJ.

Ext.CLIJ2_getDimensions(input, width, height, depth);

print("Image width: " + width);
print("Image height: " + height);
print("Image depth: " + depth);
> Image width: 256
> Image height: 254
> Image depth: 1

Image statistics

We can derive basic statistics from images, parameter by parameter.

Ext.CLIJ2_getSumOfAllPixels(input, sum_of_all_pixels);
Ext.CLIJ2_getMinimumOfAllPixels(input, min_of_all_pixels);
Ext.CLIJ2_getMaximumOfAllPixels(input, max_of_all_pixels);
Ext.CLIJ2_getMeanOfAllPixels(input, mean_of_all_pixels);

print("Sum: " + sum_of_all_pixels);
print("Min: " + min_of_all_pixels);
print("Max: " + max_of_all_pixels);
print("Mean: " + mean_of_all_pixels);

> Sum: 6714936
> Min: 8
> Max: 248
> Mean: 103.2686

Detailed statistics

More detailed statistics can be done by this method. Note: an empty table will be handed over.


Ext.CLIJ2_statisticsOfImage(input);

IDENTIFIERBOUNDING_BOX_XBOUNDING_BOX_YBOUNDING_BOX_ZBOUNDING_BOX_END_XBOUNDING_BOX_END_YBOUNDING_BOX_END_ZBOUNDING_BOX_WIDTHBOUNDING_BOX_HEIGHTBOUNDING_BOX_DEPTHMINIMUM_INTENSITYMAXIMUM_INTENSITYMEAN_INTENSITYSUM_INTENSITYSTANDARD_DEVIATION_INTENSITYPIXEL_COUNTSUM_INTENSITY_TIMES_XSUM_INTENSITY_TIMES_YSUM_INTENSITY_TIMES_ZMASS_CENTER_XMASS_CENTER_YMASS_CENTER_ZSUM_XSUM_YSUM_ZCENTROID_XCENTROID_YCENTROID_ZSUM_DISTANCE_TO_MASS_CENTERMEAN_DISTANCE_TO_MASS_CENTERMAX_DISTANCE_TO_MASS_CENTERMAX_MEAN_DISTANCE_TO_MASS_CENTER_RATIOSUM_DISTANCE_TO_CENTROIDMEAN_DISTANCE_TO_CENTROIDMAX_DISTANCE_TO_CENTROIDMAX_MEAN_DISTANCE_TO_CENTROID_RATIO
0000255253025625418248103.269671493671.057650248694619768459746720129.482125.9840829056082255360127.500126.50006344833.76597.577181.3801.8596343893.23397.562179.6071.841

At the end of the macro, clean up.