[Insight-users] problem reading dicom files

h h hossein9876 at gmail.com
Mon Apr 7 07:23:00 EDT 2008


Hi luis,
I did the procedure you described in part b and it didnt make a difference.
I've uploaded 2 dicom files:
1- http://myfreefilehosting.com/f/b97bbaf518_0.27MB
2- http://myfreefilehosting.com/f/ee1443e018_0.5MB

Its strange. The function i wrote reads the 2nd file correctly but it
gives incorrect data for the first file. This is the output that i got
for both files when i followed the procedure you described in a:
First file: (img57)
////////////////////////////////////////////////////////////
Must downscale data from 16 bits to 12
Image (00C11250)
  RTTI typeinfo:   class itk::Image<short,2>
  Reference Count: 2
  Modified Time: 29
  Debug: Off
  Observers:
    none
  Source: (00C0EAC0)
  Source output index: 0
  Release Data: Off
  Data Released: False
  Global Release Data: Off
  PipelineMTime: 16
  UpdateMTime: 30
  LargestPossibleRegion:
    Dimension: 2
    Index: [0, 0]
    Size: [512, 512]
  BufferedRegion:
    Dimension: 2
    Index: [0, 0]
    Size: [512, 512]
  RequestedRegion:
    Dimension: 2
    Index: [0, 0]
    Size: [512, 512]
  Spacing: [0.283203, 0.283203]
  Origin: [-72.3584, -272.358]
  Direction:
1 0
0 1

  PixelContainer:
    ImportImageContainer (00B76090)
      RTTI typeinfo:   class itk::ImportImageContainer<unsigned long,short>
      Reference Count: 1
      Modified Time: 27
      Debug: Off
      Observers:
        none
      Pointer: 00B760C0
      Container manages memory: true
      Size: 262144
      Capacity: 262144
/////////////////////////////////////////////////


second file(im50)
///////////////////////////////////////////
Image (002C1250)
  RTTI typeinfo:   class itk::Image<short,2>
  Reference Count: 2
  Modified Time: 29
  Debug: Off
  Observers:
    none
  Source: (002BEAC0)
  Source output index: 0
  Release Data: Off
  Data Released: False
  Global Release Data: Off
  PipelineMTime: 16
  UpdateMTime: 30
  LargestPossibleRegion:
    Dimension: 2
    Index: [0, 0]
    Size: [512, 512]
  BufferedRegion:
    Dimension: 2
    Index: [0, 0]
    Size: [512, 512]
  RequestedRegion:
    Dimension: 2
    Index: [0, 0]
    Size: [512, 512]
  Spacing: [0.242188, 0.242188]
  Origin: [-61.8789, -284.879]
  Direction:
1 0
0 1

  PixelContainer:
    ImportImageContainer (00226090)
      RTTI typeinfo:   class itk::ImportImageContainer<unsigned long,short>
      Reference Count: 1
      Modified Time: 27
      Debug: Off
      Observers:
        none
      Pointer: 002260C0
      Container manages memory: true
      Size: 262144
      Capacity: 262144
/////////////////////////////////////////

regards
hossein

On 4/7/08, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>
>
> Hi h h,
>
>
> Please try the following:
>
>
> a) just after calling reader->Update(), add the following lines:
>
>     InputImageType::ConstPointer inputImage = reader->GetOutput();
>
>     inputImage->Print( std::cout );
>
>     and post to the list the output with the details of the image.
>
> b) instead of building the region by yourself, get the region
>     from the image itself, like:
>
>       InputImageType::RegionType inputRegion =
>                   inputImage->GetBufferedRegion();
>
>        ConstIteratorType inputIt(reader->GetOutput(), inputRegion);
>
>
>
>    Regards,
>
>
>
>        Luis
>
>
>
> -------------
> h h wrote:
> > Hi,
> > I want to read a dicom file and copy the image data to a buffer using
> > iterators. This is the function i used:
> >
> > #include "itkImage.h"
> > #include "itkImageFileReader.h"
> > #include "itkGDCMImageIO.h"
> > #include "itkImageRegionConstIterator.h"
> > #include "itkImageRegionIterator.h"
> >
> > void readdicomimage(char * input_file,unsigned short *imagedata)
> >        {
> >                 typedef unsigned short InputPixelType;
> >                 const unsigned int   InputDimension = 2;
> >                 typedef itk::Image< InputPixelType, InputDimension >
> > InputImageType;
> >                 typedef itk::ImageFileReader< InputImageType > ReaderType;
> >                 ReaderType::Pointer reader = ReaderType::New();
> >                 reader->SetFileName(input_file);
> >                 typedef itk::GDCMImageIO ImageIOType;
> >                 ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
> >                 reader->SetImageIO(gdcmImageIO);
> >                 reader->Update();
> >
> >                 typedef itk::ImageRegionConstIterator< InputImageType
> >
> >>ConstIteratorType;
> >
> >                 typedef itk::ImageRegionIterator< InputImageType>
> >  IteratorType;
> >
> >                 InputImageType::RegionType inputRegion;
> >                 InputImageType::RegionType::IndexType inputStart;
> >                 InputImageType::RegionType::SizeType  size;
> >                 inputStart[0] = 0;
> >                 inputStart[1] = 0;
> >                 size[0]  = 512;
> >                 size[1]  = 512;
> >                 inputRegion.SetSize( size );
> >                inputRegion.SetIndex( inputStart );
> >                 ConstIteratorType inputIt(reader->GetOutput(),
> inputRegion);
> >                 for ( inputIt.GoToBegin();
> > !inputIt.IsAtEnd();++inputIt,++imagedata)
> >                 {
> >                 *imagedata = inputIt.Get();
> >                 }
> >
> >        }
> >
> > The above function takes 2 arguments, first is the input file and
> > second is a pointer to the buffer i want to copy the image data to.
> > Now the problem:
> > All the pixel data which the iterator returns are numbers which have
> > the following pattern :
> > 0xFCnn eg. 0xFB45, 0xFBEA, 0XFB5C. As you can see the most significant
> > byte is constant (FC) and its value dosn't change.
> >
> > What is wrong here?
> >
> > p.s.  Im using itk 3.2. Changing the input pixel type to signed short
> > dosn't help either.
> >
> > here is a url to the image i am trying to read:
> > http://myfreefilehosting.com/f/b97bbaf518_0.27MB
> > the file name is "img57"
> >
> >
> > regards
> > hossein
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
> >
>


More information about the Insight-users mailing list