Skip to content

Commit

Permalink
added pushAs
Browse files Browse the repository at this point in the history
  • Loading branch information
haesleinhuepf committed Mar 28, 2021
1 parent 17178e6 commit edd828c
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/main/java/net/haesleinhuepf/clijx/plugins/PushAs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package net.haesleinhuepf.clijx.plugins;

import ij.ImagePlus;
import ij.WindowManager;
import net.haesleinhuepf.clij.CLIJ;
import net.haesleinhuepf.clij.clearcl.ClearCLBuffer;
import net.haesleinhuepf.clij.macro.CLIJHandler;
import net.haesleinhuepf.clij.macro.CLIJMacroPlugin;
import net.haesleinhuepf.clij.macro.CLIJOpenCLProcessor;
import net.haesleinhuepf.clij.macro.documentation.OffersDocumentation;
import net.haesleinhuepf.clij2.AbstractCLIJ2Plugin;
import org.scijava.plugin.Plugin;

/**
* Release
* <p>
* <p>
* <p>
* Author: @haesleinhuepf
* 12 2018
*/

@Plugin(type = CLIJMacroPlugin.class, name = "CLIJx_pushAs")
public class PushAs extends AbstractCLIJ2Plugin implements CLIJMacroPlugin, CLIJOpenCLProcessor, OffersDocumentation {

@Override
public boolean executeCL() {
String source_name = (String)args[0];
String target_name = (String)args[1];

if (WindowManager.getImage(source_name) == null) {
//Macro.abort();
throw new IllegalArgumentException("You tried to push the image '" + source_name + "' to the GPU.\n" +
"However, this image doesn't exist.");
} else {
ImagePlus imp = WindowManager.getImage(source_name);
imp.changes = false;

ClearCLBuffer temp = CLIJ.getInstance().push(imp);
CLIJHandler.getInstance().pushInternal(temp, target_name);
//.pushToGPU((String) args[0]);
}
return true;
}

@Override
public String getParameterHelpText() {
return "String image, String new_name";
}

@Override
public String getDescription() {
return "Copies an image specified to GPU memory and gives it a new name in order to process it there later.\n\n" +
"This function is only available via ImageJ Macro.";
}

@Override
public String getAvailableForDimensions() {
return "2D, 3D";
}

}
22 changes: 22 additions & 0 deletions src/main/macro/push_as.ijm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// clean up first
run("Close All");
run("Clear Results");

// open the blobs exmple image
open("http://imagej.nih.gov/ij/images/blobs.gif");
run("Invert LUT");
/*
We now initialize the GPU and push the image to GPU memory under a given name "A"
*/
run("CLIJ2 Macro Extensions", "cl_device=");
Ext.CLIJ2_clear();

// push image to GPU memory
blobs = getTitle();
Ext.CLIJx_pushAs(blobs, "A");
/*
Then, we process the image "A".
*/
radius = 1;
Ext.CLIJ2_detectMaxima2DBox("A", maxima, radius, radius);
Ext.CLIJ2_pull(maxima);

0 comments on commit edd828c

Please sign in to comment.