java.io.EOFException while reading vicar file

27 views
Skip to first unread message

Martin Spel

unread,
Jul 25, 2018, 5:18:57 PM7/25/18
to VICAR Open Source

I'm having a problem reading a VICAR file with the open source version.

With an older version code below worked, with 2.0 I'm getting an EOF exception.
Any help would be appreciated.



import java.awt.image.Raster;


import com.sun.media.jai.codec.FileSeekableStream;

import com.sun.media.jai.codec.SeekableStream;


import jpl.mipl.io.codec.VicarImage;


public class testVicar {


        public static void main(String[] args) throws Exception {

                String mFileName = "D_L000N5096_ZZZ001006ORRAS_TWKSPC15M1.VIC";


                SeekableStream stream=new FileSeekableStream(mFileName);

                VicarImage image = new VicarImage(stream);

                Raster imageData = image.getData();

                System.out.println("test " + imageData.getWidth());

        }

}




java.io.EOFException

        at com.sun.media.jai.codec.SeekableStream.readFully(SeekableStream.java:320)

        at jpl.mipl.io.streams.ImageInputStreamStride.readFully(ImageInputStreamStride.java:350)

        at jpl.mipl.io.streams.ImageInputStreamStride.readFloats(ImageInputStreamStride.java:301)

        at jpl.mipl.io.vicar.VicarInputFile.readRecordNS(VicarInputFile.java:1088)

        at jpl.mipl.io.vicar.VicarInputFile.readTile(VicarInputFile.java:2085)

        at jpl.mipl.io.vicar.VicarInputFile.readTile(VicarInputFile.java:1491)

        at jpl.mipl.io.codec.VicarImage.computeTile(VicarImage.java:338)

        at jpl.mipl.io.codec.VicarImage.getTile(VicarImage.java:358)

        at jpl.mipl.io.codec.SimpleRenderedImage.getData(SimpleRenderedImage.java:459)

        at jpl.mipl.io.codec.SimpleRenderedImage.getData(SimpleRenderedImage.java:415)

        at testVicar.main(testVicar.java:18)

Bob Deen

unread,
Jul 25, 2018, 5:38:41 PM7/25/18
to Martin Spel, VICAR Open Source, Walt Bunch
Hi Martin...

Can you send me (privately) the image you're trying to read? It looks
like an InSight mosaic.

I don't recall anything changing in that code between versions 1 and 2
but I can't rule it out either until we research it.

Thanks...

-Bob
> --
> You received this message because you are subscribed to the Google
> Groups "VICAR Open Source" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to vicar-open-sou...@googlegroups.com
> <mailto:vicar-open-sou...@googlegroups.com>.
> To post to this group, send email to vicar-op...@googlegroups.com
> <mailto:vicar-op...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vicar-open-source/9914f0f2-1936-4030-a25f-2a9e139b6176%40googlegroups.com
> <https://groups.google.com/d/msgid/vicar-open-source/9914f0f2-1936-4030-a25f-2a9e139b6176%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Bob Deen

unread,
Jul 27, 2018, 12:15:42 PM7/27/18
to Martin Spel, VICAR Open Source, Walt Bunch
Hi Martin...

Thanks for the sample images.

Turns out something DID change between VOS versions 1 and 2 that broke
this. We'll have to fix that. The access pattern you're using is not
one we use, hence we haven't run into the bug. However, there's an
alternate way of doing the same thing, that gets you a Raster of the
entire image. See below.

BTW, this is not the most efficient nor standard way to access image
data from Java... but it is among the simplest. More efficient would be
to access data as tiles, so it's read as needed rather than having to
hold the whole thing in memory at once. But, that's a lot more
complicated code to write.

More standard (and both simpler, and file-format-agnostic) would be to
use the Java Advanced Imaging (JAI) API to read the file.
Unfortunately, this appears to be impacted by the same bug - which is
odd since this is a standard access mechanism we use, so I'm not sure
why we haven't run across it. I've included it below as
testVicar2.java, which will work once the bug is fixed.

BTW we are currently working on a release 3 of VICAR Open Source, we
hope to have it out in a matter of weeks. We'll try to get this bug
fixed before the release. So you shouldn't have to wait long. In the
meantime, the sample code below should work.

-Bob


EXAMPLE 1
---------
This code works now, but is a little messy.




import java.awt.image.Raster;
import com.sun.media.jai.codec.FileSeekableStream;
import com.sun.media.jai.codec.SeekableStream;
import jpl.mipl.io.vicar.VicarInputFile;
import jpl.mipl.io.plugins.VicarRenderedImage;

public class testVicar {

public static void main(String[] args) throws Exception {

//String mFileName =
"D_L000N5096_ZZZ001006ORRAS_TWKSPC15M1.VIC"
;
String mFileName = args[0];

// Access the file the hard way, to work around the bug

SeekableStream stream=new FileSeekableStream(mFileName);
VicarInputFile vif = new VicarInputFile();
vif.open(stream);
VicarRenderedImage vri = new VicarRenderedImage(vif, null);

Raster imageData = vri.getData();

System.out.println("test " + imageData.getWidth());
}
}




EXAMPLE 2
---------
This is a better access pattern but doesn't work for VICAR files right
now due to the bug. It does work for other types of images.



import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import javax.media.jai.JAI;

public class testVicar2 {

public static void main(String[] args) throws Exception {
String mFileName = args[0];

RenderedImage img = JAI.create("imageread", mFileName);

Raster imageData = img.getData();

System.out.println("test " + imageData.getWidth());
Reply all
Reply to author
Forward
0 new messages