[ITK-users] emscripten itkImageReader

Juan Carlos Prieto juanprietob at gmail.com
Tue Nov 3 22:07:09 EST 2015


Apologies,

I found the error in my code, now it works!

var itkImageJS = new module.itkImageJS();
console.log("Installing file: ");
var input_filepath = '/raw/test.nii.gz';
FS.writeFile(input_filepath, *new Uint8Array(imagedata)*, { encoding:
'binary' });

var stat = FS.stat(input_filepath);//The file exists!
itkImageJS.ReadImage(input_filepath);



Best regards,

Juan



On Tue, Nov 3, 2015 at 8:55 PM, Juan Carlos Prieto <juanprietob at gmail.com>
wrote:

> Dear all,
>
> I have started using emscripten to develop a plugin to read medical images
> in the browser.
>
> I have a compiled version of my code that works in Node.js.
> I am able to read an image, manipulate the data and write the image.
>
> However, whenever I tried to execute the same code in the browser, the
> itk::ImageReader seems to be creating a reader for PNG only.
>
> This is an example code that I am execuitng:
>
> var itkImageJS = new module.itkImageJS();
> console.log("Installing file: ");
> var input_filepath = '/raw/test.nii.gz';
> FS.writeFile(input_filepath, imagedata, { encoding: 'binary' });
>
> var stat = FS.stat(input_filepath);//The file exists!
>
> itkImageJS.ReadImage(input_filepath);
>
>
> And this is the output from the exception:
>
> itk::ExceptionObject (0x6a5710)
> testFS.js:1 Location: "unknown"
> testFS.js:1 File: .../ITK/Modules/IO/PNG/src/itkPNGImageIO.cxx
> testFS.js:1 Line: 107
> testFS.js:1 Description: itk::ERROR: PNGImageIO(0x975628): PNGImageIO
> failed to read header for file:
> testFS.js:1 Reason: fread read only 0 instead of 8
>
> Instead of creating the reader for a Nifti image, the reader is for PNG
> image.
>
> Is it possible to read other type of files in the browser?
> Do I have to read the data server side and stream it to the client?
>
> Any comments or suggestions will be greatly appreciated.
>
> Best regards,
>
> Juan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20151103/073c2fd3/attachment.html>


More information about the Insight-users mailing list