Skip to content

Instantly share code, notes, and snippets.

@ozooxo
Created November 5, 2014 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozooxo/cfca2c531824b6925260 to your computer and use it in GitHub Desktop.
Save ozooxo/cfca2c531824b6925260 to your computer and use it in GitHub Desktop.
Use ImageJ as a third party java library
wget "http://imagej.nih.gov/ij/download/linux/ij148-linux64.zip"
unzip ij148-linux64.zip
cd ImageJ
jar -xvf ij.jar # simply do
# $ javac -classpath '.:ij.jar' Algorithm.java
# $ java Algorithm
# will cause run time error for not finding some particular classes
# (which are actually in the .jar file). Reason unknown.
cd ..
mv ImageJ/ij ij
rm -rf ImageJ
cat >Algorithm.java <<EOL
import ij.*;
import ij.process.*;
public class Algorithm {
public static void main(String[] args) {
ImageProcessor ip = new ByteProcessor(400, 400);
String title = "My new image";
ImagePlus imp = new ImagePlus(title, ip);
IJ.saveAs(imp, "tif", "image.tif");
}
}
EOL
javac Algorithm.java
java Algorithm # it will save a blank file "image.tif" in the current folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment