-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17178e6
commit edd828c
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |