Permalink
Find file Copy path
5cdfda3 Dec 10, 2018
1 contributor

Users who have contributed to this file

43 lines (33 sloc) 1.02 KB
// ClearCLIJ example macro: backgroundSubtraction.ijm
//
// This macro shows how background subtraction can be done in the GPU.
//
// Author: Robert Haase
// December 2018
// ---------------------------------------------
// Get test data
//open("C:/structure/data/t1-head.tif");
run("T1 Head (2.4M, 16-bits)");
input = getTitle();
background = "background";
background_subtracted = "background_subtracted";
run("Duplicate...", "title=maximum_projected");
maximum_projected = getTitle();
// Init GPU
run("CLIJ Macro Extensions", "cl_device=");
Ext.CLIJ_clear();
// push images to GPU
Ext.CLIJ_push(input);
Ext.CLIJ_push(maximum_projected);
// CleanUp ImageJ
close();
// Blur in GPU
Ext.CLIJ_blur3d(input, background, 20, 20, 1, 10, 10, 1);
// subtraction from original
Ext.CLIJ_addWeightedPixelwise(input, background, background_subtracted, 1, -1);
// maximum projection
Ext.CLIJ_maxProjection(background_subtracted, maximum_projected);
// Get results back from GPU
Ext.CLIJ_pull(maximum_projected);
// Cleanup by the end
Ext.CLIJ_clear();