jpg2000


(Ludo F) #1

Hi everyone,
I would like to process histological images with simpleITK or ITK saved as jpg2000 format.
It seems that simpleITK doesn’t handle this format. Is it possible to register this specific format in simpleITK or ITK ?
Best regards
Ludovic


(Bradley Lowekamp) #2

Do you have a sample image? What file extensions do your files have?


(Bradley Lowekamp) #3

This patch here in review:
http://review.source.kitware.com/#/c/23803/2

This should make the JPEG2000 ImageIO behave like a normal IO module. When this patch gets merged, SimpleITK can be compiled with the " Module_ITKIOJPEG2000:BOOL=ON" enabled to get support for JPEG2000.


(Dženan Zukić) #4

Without this patch, JPEG2000 support is in Review module. To get it, turn on Module_ITKReview in CMake configuration and rebuild ITK.


(Bradley Lowekamp) #5

This enables the support, but then the factory needs to be manually registered via “itk::JPEG2000ImageIOFactory::JPEG2000ImageIOFactory()” or explicitly set to the reader via “itk::ImageFileReader::SetImageIO” with a constructed JPEG2000ImageIO object.


(Ludo F) #6

Thank you for your reply.
Ok for patching and rebuilding ITK.

  • Would SimpleITK be affected by this patch once a proper rebuild has been performed ?
  • Would it be possible to load a huge image file by smaller patches without RAM overload ?
    Regards
    Ludovic

(Bradley Lowekamp) #7

After the patch is merged into ITK master you can compile the current development SimpleITK from git with ITKv5 and JPEG2000 support with the following configuration command:

cmake
   -DModule_ITKIOJPEG2000:BOOL=ON
   -DCMAKE_CXX_STANDARD:STRING=11
   -DITK_GIT_TAG:STRING=master
   -DITKV4_COMPATIBILITY:BOOL=ON
   -DITK_LEGACY_REMOVE:BOOL=OFF
   SimpleITK/SuperBuild

Also in the development version of SimpleITK is support for IO Streaming. This adds sitk::ImageFileReader::SetExtractIndex andsitk::ImageFileReader::SetExtractSize methods which allows setting a sub region of the image file to read. This can be used after the sitk::ImageFileReader::ReadInformation method has been called to determine the size and type of the image.


(Ludo F) #8

Thank you very much.
I will try to get this done and come back here to report how it’ll end.
Regards.
Ludovic


(Ludo F) #9

I had these warning during configuration process. I am not sure what does mean or if this will have an effect on my ITK installation with jpg2000 support

Blockquote
CMake Error at Wrapping/Generators/SwigInterface/CMakeLists.txt:377
(add_dependencies):
The dependency target “ITKIOJPEG2000Swig” of target “ITKReviewSwig” does
not exist.
Call Stack (most recent call first):
Wrapping/Generators/CMakeLists.txt:87 (itk_end_wrap_module_swig_interface)
Wrapping/TypedefMacros.cmake:123 (itk_end_wrap_module_all_generators)
Modules/Nonunit/Review/wrapping/CMakeLists.txt:3 (itk_end_wrap_module)

CMake Error at Wrapping/Generators/Python/CMakeLists.txt:556
(add_dependencies):
The dependency target “ITKIOJPEG2000Swig” of target “ITKReviewPython” does
not exist.
Call Stack (most recent call first):
Wrapping/Generators/CMakeLists.txt:90 (itk_end_wrap_module_python)
Wrapping/TypedefMacros.cmake:123 (itk_end_wrap_module_all_generators)

Regards
Ludovic


(Ludo F) #10

Hi,
Apparently, a header file is missing in my installation

Blockquote
/ITK/Modules/IO/JPEG2000/include/itkJPEG2000ImageIO.h:23:33: fatal error: ITKIOJPEG2000Export.h: Aucun fichier ou dossier de ce type
compilation terminated.

Maybe, I am doing something wrong while getting the patch ?
Regards
Ludovic


(Bradley Lowekamp) #11

That error is reported by the itk gerrit robots. I was unable to reproduce it yesterday.

I’ll look into it today, do you the configuration you used?


(Ludo F) #12

Hi,
Configuration ? you mean CMakeCache.txt or OS and the like ?


(Bradley Lowekamp) #13

I was able to find the problem with the patch and it is fixed in the patch/4 now: http://review.source.kitware.com/#/c/23803/4

It was a silly case issue with a filename.


(Ludo F) #14

Hi,
OK, your patches made the compilation successful. However, when I want to wrap itk5 with python, I got an additional error at compilation time:

Wrapping/Typedefs/itkJPEG2000ImageIO.i:29: Warning 401: Nothing known about base class ‘itk::StreamingImageIOBase’. Ignored.
/home/physiciens/itk_5/build/Wrapping/Typedefs/itkJPEG2000ImageIO.i:54: Warning 401: Nothing known about base class ‘itk::ObjectFactoryBase’. Ignored

BTW, thank you for effort.
Regards
Ludovic


(Bradley Lowekamp) #15

Have you tried building SimpleITK against the patched version of ITK?


(Ludo F) #16

Hi,
Not yet. I was thinking first to give a try to itk as it appears to be more complete than simpleitk.
Do you think I should go with SimpleITK first ?
Regards
Ludovic


(Bradley Lowekamp) #17

I am a SimpleITK developer. The patch has been merged into ITK master. The recommended configuration for SimpleITK below, enables reading of JPEG2000 images. It worked for me.


(Ludo F) #18

Hi,
I used the line you provided me and compiled successfully once configuration finished. i create a virtual environment inside the compiled tree. But still, sitk.ReadImage doesn’t open my file .

sitk::ERROR: Unable to determine ImageIO reader for “./07_test_14.jp2”

I suspect I’m doing something wrong or missing something because sitk.Version() pointed me to 4.13 version. I thought we were on the 5th.

I got sitk source from git repository via clone command. BTW, I saw your last commit few days ago, but apparently not the ones on jpg2000. But, I may be wrong.
Regards
Ludovic


(Bradley Lowekamp) #19

What is the output of the following command: python -c "import SimpleITK as sitk; print(sitk.ImageFileReader())" I am getting the following:

itk::simple::ImageFileReader
  FileName: ""
  ExtractSize: [ ]
  ExtractIndex: [ ]
  Image Information:
    PixelType: Unknown pixel id
    Dimension: 0
    NumberOfComponents: 0
    Direction: [ ]
    Origin: [ ]
    Spacing: [ ]
    Size: [ ]
  OutputPixelType: Unknown pixel id
  LoadPrivateTags: 0
  ImageIOName: 
  Registered ImageIO:
	BMPImageIO ( *.bmp, *.BMP )
	BioRadImageIO ( *.PIC, *.pic )
	Bruker2dseqImageIO
	GDCMImageIO ( *.dcm, *.DCM, *.dicom, *.DICOM )
	GE4ImageIO
	GE5ImageIO
	GiplImageIO
	HDF5ImageIO ( *.hdf, *.h4, *.hdf4, *.h5, *.hdf5, *.he4, *.he5, *.hd5 )
	JPEGImageIO ( *.jpg, *.JPG, *.jpeg, *.JPEG )
	JPEG2000ImageIO ( *.j2k, *.jp2, *.jpt )
	LSMImageIO ( *.tif, *.TIF, *.tiff, *.TIFF, *.lsm, *.LSM )
	MINCImageIO ( *.mnc, *.MNC, *.mnc2, *.MNC2 )
	MRCImageIO ( *.mrc, *.rec )
	MetaImageIO ( *.mha, *.mhd )
	NiftiImageIO ( *.nia, *.nii, *.nii.gz, *.hdr, *.img, *.img.gz )
	NrrdImageIO ( *.nrrd, *.nhdr )
	PNGImageIO ( *.png, *.PNG )
	SCIFIOImageIO
	StimulateImageIO ( *.spr )
	TIFFImageIO ( *.tif, *.TIF, *.tiff, *.TIFF )
	VTKImageIO ( *.vtk )
  Debug: 0
  NumberOfThreads: 88
  Commands: (none)
  ProgressMeasurement: 0
  ActiveProcess: (none)

This shows that the JPEG2000ImageIO is registered. If this is not there then inspect your build directory to verify that the new ITKIOJPEG2000 modules exists and is enabled in the ITK build directory. Try the following:

$grep Module_ITKIOJPEG2000 ITK-build/CMakeCache.txt 
Module_ITKIOJPEG2000:BOOL=ON
//ADVANCED property for variable: Module_ITKIOJPEG2000
Module_ITKIOJPEG2000-ADVANCED:INTERNAL=1

I tried the recommended command again and it works. So verify you are using and have installed the version of SimpleITK you just compiled.


(Ludo F) #20

Hi,
Unfortunately, JP2000 is absent from the ImageFileReader list.

Registered ImageIO:
BMPImageIO ( *.bmp, *.BMP )
BioRadImageIO ( *.PIC, *.pic )
Bruker2dseqImageIO
GDCMImageIO
GE4ImageIO
GE5ImageIO
GiplImageIO
HDF5ImageIO
JPEGImageIO ( *.jpg, *.JPG, *.jpeg, *.JPEG )
LSMImageIO ( *.tif, *.TIF, *.tiff, *.TIFF, *.lsm, *.LSM )
MINCImageIO ( *.mnc, *.MNC )
MRCImageIO ( *.mrc, *.rec )
MetaImageIO ( *.mha, *.mhd )
NiftiImageIO ( *.nia, *.nii, *.nii.gz, *.hdr, *.img, *.img.gz )
NrrdImageIO ( *.nrrd, *.nhdr )
PNGImageIO ( *.png, *.PNG )
StimulateImageIO
TIFFImageIO ( *.tif, *.TIF, *.tiff, *.TIFF )
VTKImageIO ( *.vtk )

But, this feature is enable in the ITK build directory

grep Module_ITKIOJPEG2000 ITK-build/CMakeCache.txt
Module_ITKIOJPEG2000:BOOL=ON
//ADVANCED property for variable: Module_ITKIOJPEG2000
Module_ITKIOJPEG2000-ADVANCED:INTERNAL=1

Regarding tne installation of SimpleITK right after the compilation, I tried a command make install but no such rule is present in the make file. I guessed it was correct since we used Superbuild feature.
So, how do you install the just compiled SimpleITK and ITK in your python environment ? I guess I must copy some wheels or shared libraries. But is there any automatic process to do it ?
Many thanks
regards
Ludovic