[Insight-users] Reading and writing jp2 images

Prashanth Ravindran prashanth at bioimagene.com
Tue Nov 13 09:17:05 EST 2007


Hi All-

 

I am trying to use ITK to read and write (digital microscopy) jp2 images. In
doing so I used the gdcm library and explicitly forced it to treat the image
as a jpeg2000 image. This is as suggested in the forum here
(http://www.itk.org/pipermail/insight-users/2007-January/020481.html). The
code that I used to do so is as under. As of now it is a minimal snippet
that only tries to read the image. When I run this I get an error from
itkImageFileReader.txx and the error message is 

 

ImageIO returns IO region that does not fully contain the requested region 

 

Code:

...

typedef short PixelType;

typedef itk::RGBPixel<unsigned char> PixelType;

                                                // Same error appears with
RGBAPixelType as well

typedef itk::Image<PixelType, 2>    ImageType;

typedef itk::ImageFileReader<ImageType> ReaderType;

typedef itk::ImageFileWriter<ImageType> WriterType;

typedef itk::GDCMImageIO                        ImageIOType;

 

ReaderType::Pointer reader = ReaderType::New();

ImageIOType::Pointer jp2io = ImageIOType::New();

 

reader->SetFileName(argv[1]);

      jp2io->SetCompressionType(itk::GDCMImageIO::JPEG2000);

      reader->SetImageIO(jp2io);

      

      try

      {

            reader->Update();

      }

      catch(itk::ExceptionObject & excep)

      {

            std::cerr<<excep;

            return EXIT_FAILURE;

      }

...

 

NOTE: 

 

1.	When I try and use the stand alone exe's provided by the folks at
openjpeg, and use it to write a bmp, the bmp is filled with random data. ITK
does not go all the way there and trows an exception much before that.
2.	The source images where encoded using the kakadu libraries.

 

I would really appreciate if somebody could point out, what it is that I am
doing wrong, and if so what is the fix?

 

--Prashanth

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20071113/d77e505e/attachment.htm


More information about the Insight-users mailing list