GPU accelerated image processing for everyone
Authors: Robert Haase, Daniela Vorkel, April 2020
This macro shows how to retrieve basic statistics from images.
// get test data run("Blobs (25K)"); run("Invert LUT"); input = getTitle();
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");
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
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
More detailed statistics can be done by this method. Note: an empty table will be handed over.
Ext.CLIJ2_statisticsOfImage(input);
IDENTIFIER | BOUNDING_BOX_X | BOUNDING_BOX_Y | BOUNDING_BOX_Z | BOUNDING_BOX_END_X | BOUNDING_BOX_END_Y | BOUNDING_BOX_END_Z | BOUNDING_BOX_WIDTH | BOUNDING_BOX_HEIGHT | BOUNDING_BOX_DEPTH | MINIMUM_INTENSITY | MAXIMUM_INTENSITY | MEAN_INTENSITY | SUM_INTENSITY | STANDARD_DEVIATION_INTENSITY | PIXEL_COUNT | SUM_INTENSITY_TIMES_X | SUM_INTENSITY_TIMES_Y | SUM_INTENSITY_TIMES_Z | MASS_CENTER_X | MASS_CENTER_Y | MASS_CENTER_Z | SUM_X | SUM_Y | SUM_Z | CENTROID_X | CENTROID_Y | CENTROID_Z | SUM_DISTANCE_TO_MASS_CENTER | MEAN_DISTANCE_TO_MASS_CENTER | MAX_DISTANCE_TO_MASS_CENTER | MAX_MEAN_DISTANCE_TO_MASS_CENTER_RATIO | SUM_DISTANCE_TO_CENTROID | MEAN_DISTANCE_TO_CENTROID | MAX_DISTANCE_TO_CENTROID | MAX_MEAN_DISTANCE_TO_CENTROID_RATIO |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 255 | 253 | 0 | 256 | 254 | 1 | 8 | 248 | 103.269 | 6714936 | 71.057 | 65024 | 869461976 | 845974672 | 0 | 129.482 | 125.984 | 0 | 8290560 | 8225536 | 0 | 127.500 | 126.500 | 0 | 6344833.765 | 97.577 | 181.380 | 1.859 | 6343893.233 | 97.562 | 179.607 | 1.841 |
At the end of the macro, clean up.