IJ.openImage returning NULL after using BioFormats to open?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

IJ.openImage returning NULL after using BioFormats to open?

Kenneth Sloan-2
I'm dealing with a new (to me) image format.  I have two very similar images, with extensions .hdr and .img.  Both behave the same.

When I call (from Java):

        ImagePlus ipl = IJ.openImage(path);

...the Bio-Formats Import Options screen appears.
I accept all defaults (I've also tried "Standard ImageJ" instead of "Hyperstack") and a single image is displayed (perhaps it's actually a one-slice stack?)

But, ipl is null!

I'm going to workaround this by saving the image as a .tif and proceed from there - but I thought I'd ask: "what am I doing wrong"?

Question 2 - should I be surprised that the image is DISPLAYED?  My plugin wants the ImageProcessor, and will use it to create a custom ImagePlus (with  a few minor extensions).  I'm guessing that once Bio-Formats is called, all bets are off?

--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: IJ.openImage returning NULL after using BioFormats to open?

Curtis Rueden-2
Hi Kenneth,

> should I be surprised that the image is DISPLAYED?  My plugin wants
> the ImageProcessor, and will use it to create a custom ImagePlus (with
> a few minor extensions).

Try using the loci.plugins.BF API. It is intended for use from Java
libraries and plugins.

  import loci.plugins.BF;
  ...
  String file = "/path/to/your/data.hdr";
  ImagePlus[] imps = BF.openImagePlus(file);

If you need more control over how the images are opened, you can set them
using ImporterOptions; see here for details:

  https://imagej.net/Bio-Formats#Scripting

Regards,
Curtis

--
Curtis Rueden
Software architect, LOCI/Eliceiri lab - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Have you tried the Image.sc Forum? https://forum.image.sc/



On Tue, Aug 25, 2020 at 2:34 PM Kenneth Sloan <[hidden email]>
wrote:

> I'm dealing with a new (to me) image format.  I have two very similar
> images, with extensions .hdr and .img.  Both behave the same.
>
> When I call (from Java):
>
>         ImagePlus ipl = IJ.openImage(path);
>
> ...the Bio-Formats Import Options screen appears.
> I accept all defaults (I've also tried "Standard ImageJ" instead of
> "Hyperstack") and a single image is displayed (perhaps it's actually a
> one-slice stack?)
>
> But, ipl is null!
>
> I'm going to workaround this by saving the image as a .tif and proceed
> from there - but I thought I'd ask: "what am I doing wrong"?
>
> Question 2 - should I be surprised that the image is DISPLAYED?  My plugin
> wants the ImageProcessor, and will use it to create a custom ImagePlus
> (with  a few minor extensions).  I'm guessing that once Bio-Formats is
> called, all bets are off?
>
> --
> Kenneth Sloan
> [hidden email]
> Vision is the art of seeing what is invisible to others.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: IJ.openImage returning NULL after using BioFormats to open?

Kenneth Sloan-2
Curtis-

Thank you for your reply.  For other reasons, I will pre-preprocess the .hdr and create a .tif.

The point of my inquiry was to determine if the documentation for IJ.OpenImage() was incorrect, of if the implementation was broken, or if I was confused.

--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html