imagej - Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [B -


i tried read image loci tools , save filesaver imagej but, got error when running it

imageplus[] imps = bf.openimageplus("path/to/my/file"); (imageplus imp : imps)new filesaver(imp).saveasraw("e:/test.raw"); 

when run code, shows

exception in thread "main" java.lang.classcastexception: [ljava.lang.object; cannot cast [b @ ij.io.imagewriter.write(imagewriter.java:272) @ ij.io.filesaver.saveasraw(filesaver.java:494) @ skripsi.dcmtoraw.main(dcmtoraw.java:16) 

this bug, although it's not trivial whether bug in imagej 1.x, or in bio-formats plugins.

in imagej 1.x code, imagewriter assumes (unchecked) pixels array object[] when image stack, , byte[] when it's single image plane. however, seems bio-formats produces imageplus objects pixels object[] single planes. (is image single plane?)

you work around issue using bio-formats exporter plugin save data.

or use imagej2 api, use scifio under hood:

/**  * adapted  * <a href="https://github.com/imagej/imagej-tutorials">imagej tutorials</a>  * {@code loadanddisplaydataset} tutorial.  */ @plugin(type = command.class, menupath = "plugins>my useful command") public class usefulcommand implements command {    @parameter   private datasetioservice datasetioservice;    @parameter   private logservice log;    @parameter   private file destination;    @parameter   private dataset image;    @override   public void run() {     try {       image = datasetioservice.save(image, destination.getabsolutepath());     }     catch (final ioexception exc) {       log.error(exc);     }   }  } 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -