Re: Java displaying TIF
Posted by
Wayne Rasband on
Jan 27, 2008; 7:17pm
URL: http://imagej.273.s1.nabble.com/Java-displaying-TIF-tp3697368p3697369.html
Here is a Java program that uses ImageJ as a library to display a
TIFF file:
import ij.*;
import java.awt.*;
public class Test {
public static void main(String[] args) {
ImagePlus imp = IJ.openImage(args[0]);
imp.show();
}
}
It also opens and displays any other format supported by ImageJ,
including JPEG, PNG, GIF, BMP, PGM, DICOM and FITS.
I compiled and ran it using
javac -cp ij.jar Test.java
java -cp ij.jar:. Test blobs.tif
which assumes ij.jar and blobs.tif are in the current directory.
To get an AWT image use
ImagePlus imp = IJ.openImage(args[0]);
Image img = imp.getImage();
Note that ImageJ only opens uncompressed TIFFs or LZW compressed TIFFs.
-wayne
On Jan 26, 2008, at 6:12 PM, Jack Breon wrote:
> Does anyone know where I can find a java example of using the
> imageJ library
> to display a .tif image?
>
> Is it possible to use this library to display them within your own
> applications or must you use the imagej interface always?
>
>
>
> Thanks,
>
> Jack