[ITK] [ITK-users] emscripten itkImageReader

Matt McCormick matt.mccormick at kitware.com
Tue Nov 3 23:24:44 EST 2015


Hi Juan,

Good to hear -- thanks for sharing!


Side note -- by using

  find_package(ITK REQUIRED COMPONENTS ModuleA ModuleB IOModuleA IOModuleB ... )

you can specify what IO modules to support.  If COMPONENTS is not
specified, then all the available modules are used.  However, for
Emscripten, this can greatly increase the .js file size.  So, limiting
the modules to the formats is a way to improve .js file size.

Cheers,
Matt

On Tue, Nov 3, 2015 at 10:07 PM, Juan Carlos Prieto
<juanprietob at gmail.com> wrote:
> 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
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
>
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list