2
$\begingroup$

I have raw images that I can import and view with ImageJ. They are the output of a program which I don't have the source code for, so I'm stuck with the output format.

They are imported as follows with ImageJ:

Image type: 16 bit Unsigned

Width: 320

Height: 25600

Offset to fist image: 0 bytes

Number of images: 1

Gap Between images: 0 bytes

White is zero unchecked

Little-endian byte order unchecked

Open all files in folder unchecked

use virtual stack unchecked.

Essentially each raw file is a stack of 100 320 x 256 images.

When I try importing via "Import[]" in Mathematica, I get

LibraryFunction::rterr: An error with return code -2 was encountered evaluating the function ReadImageRAW.

Import::fmterr: Cannot import data as Raw format.

I can't seem to find any info on the first error message.

$\endgroup$
  • $\begingroup$ Maybe the import filters "RawBitmap" or "BMP" with their various options may help. Have a look at their documentation. Since you do not provide example files, you have to try it on your own. $\endgroup$ – Henrik Schumacher Jan 10 at 16:52
  • $\begingroup$ Thanks for the response! I think RawBitmap is getting me closer, but it's giving me Import::coerr: Invalid setting ImageSize -> {320,25600}. $\endgroup$ – 2close2see Jan 10 at 17:14
  • 2
    $\begingroup$ You may also try Import[file, "UnsignedInteger16"] and convert it to an image with Image. $\endgroup$ – Henrik Schumacher Jan 10 at 17:21
  • $\begingroup$ BRILLIANT! "UnsignedInteger16" worked. Thanks so much....it entered everything as a list of all 8 million values so I'll have to do some massaging to get the formatting right, but that's a huge help. $\endgroup$ – 2close2see Jan 10 at 17:34
1
$\begingroup$
images = Image /@ ArrayReshape[Import[file, "UnsignedInteger16"], {100, 256, 320}];
$\endgroup$
  • $\begingroup$ I have not tested this but I believe that this (or a small variation of it) should do the trick. $\endgroup$ – Henrik Schumacher Jan 10 at 17:41
  • 1
    $\begingroup$ It looks like the width and height were switched, but the output doesn't look quite right. comparison with imageJ output Again, thanks so much for the help! $\endgroup$ – 2close2see Jan 10 at 18:29
  • $\begingroup$ images = Image /@ ArrayReshape[Import[file, "UnsignedInteger16"], {100, 256, 320}] ended up being the winner...thank you so much! $\endgroup$ – 2close2see Jan 10 at 19:12
  • $\begingroup$ You're welcome! $\endgroup$ – Henrik Schumacher Jan 10 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.