0

I have created a GUI using java Swing which displays some images. I have been testing it and have managed to create some labels which I have filled with JPEG images as a test.

Now, I face the problem that I cannot display the actual files i need to display because they are .nd2 files (from a Nikon microscope). I have been looking at how to use the Bio-formats and/or IJ packages to do so...but I don't know where to start.

Can anyone help? I am using the Eclipse IDE for Java

Chris
  • 1

1 Answers1

0

About the format

From https://www.file-extensions.org/

... The ND2 format uses JPEG-2000 compression, and also can be uncompressed or Zip-compressed ...

As mentioned in read jpeg2000 files in java JPEG 2000 seems to be not included inside standard Java SDK.

Potential solutions

1. Use Open JPEG + existing JNI wrapper

I would try out https://github.com/uclouvain/openjpeg and search for some java wrappers to use openjpeg (e.g. look at https://github.com/barmintor/openjpeg for an JNI approach for maven).

2. Use Open JPEG + Write own JNI wrapper

Another approach would be to look at https://github.com/ThalesGroup/JP2ForAndroid/blob/master/library/src/main/java/com/gemalto/jp2/JP2Decoder.java , inspect involved classes etc. and write an own JNI wrapper

The mentioned github reposoitory code writes to android bitmap, so not directly usable for your Swing project, but it shows you the way to decode JPEG2000 format by native calls to OpenJPEG library

How to convert a byte[] to a BufferedImage in Java? describes conversion from byte array to a buffered image - so these information should help you to read the image data into a buffered image (so usable in Swing).

de-jcup
  • 1,402
  • 12
  • 27