[Insight-users] Reading/writing multiframe DICOM files?

motes motes mort.motes at gmail.com
Wed Jun 10 08:33:28 EDT 2009


ok I am now trying to follow the example from the ItkSoftwareGuide.pdf page
330. I have made a new project using ITK 3.12.0 (just copied the HelloWorld
example) and in the source file I have:

#include "itkImage.h"
#include <iostream>
#include "itkGDCMImageIO.h"
#include "itkGDCMSeriesFileNames.h"
#include "itkImageSeriesReader.h"
#include "itkImageFileWriter.h"

int main( int argc, char* argv[] )
{

    if( argc < 3 ){
        std::cerr << "Usage: " << std::endl;
        std::cerr << argv[0] << " DicomDirectory  outputFileName
[seriesName]"
            << std::endl;
        return EXIT_FAILURE;
    }

  const unsigned int Dimension = 3;
    typedef signed short
PixelType;
    typedef itk::Image< PixelType, Dimension >        ImageType;
    typedef itk::ImageSeriesReader< ImageType >        ReaderType;

    ReaderType::Pointer bob = ReaderType::New();  // This line gives a
linker error.
...
...


But the last line:


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


gives the following linker errors when compiling using Visual Studio 2008 on
Vista 64:

>HelloWorld.obj : error LNK2019: unresolved external symbol "public: static
class itk::SmartPointer<class itk::ImageIOBase> __cdecl
itk::ImageIOFactory::CreateImageIO(char const *,enum
itk::ImageIOFactory::FileModeType)" (?CreateImageIO at ImageIOFactory@itk@
@SA?AV?$SmartPointer at VImageIOBase@itk@@@2 at PBDW4FileModeType@12@@Z)
referenced in function __catch$?GenerateOutputInformation@
?$ImageFileReader at V?$Image at F$02 at itk@@V?$DefaultConvertPixelTraits at F@2@@itk@
@UAEXXZ$0
1>HelloWorld.obj : error LNK2019: unresolved external symbol "public:
virtual __thiscall itk::ImageIORegion::~ImageIORegion(void)"
(??1ImageIORegion at itk@@UAE at XZ) referenced in function "public: virtual void
__thiscall itk::ImageFileReader<class itk::Image<short,3>,class
itk::DefaultConvertPixelTraits<short> >::EnlargeOutputRequestedRegion(class
itk::DataObject *)" (?EnlargeOutputRequestedRegion@?$ImageFileReader at V
?$Image at F$02 at itk@@V?$DefaultConvertPixelTraits at F@2@@itk@@UAEXPAVDataObject at 2
@@Z)
1>HelloWorld.obj : error LNK2019: unresolved external symbol "public:
__thiscall itk::ImageIORegion::ImageIORegion(unsigned int)"
(??0ImageIORegion at itk@@QAE at I@Z) referenced in function "public: virtual void
__thiscall itk::ImageFileReader<class itk::Image<short,3>,class
itk::DefaultConvertPixelTraits<short> >::EnlargeOutputRequestedRegion(class
itk::DataObject *)" (?EnlargeOutputRequestedRegion@?$ImageFileReader at V
?$Image at F$02 at itk@@V?$DefaultConvertPixelTraits at F@2@@itk@@UAEXPAVDataObject at 2
@@Z)
1>HelloWorld.obj : error LNK2019: unresolved external symbol "public: long
__thiscall itk::ImageIOBase::GetImageSizeInBytes(void)const "
(?GetImageSizeInBytes at ImageIOBase@itk@@QBEJXZ) referenced in function
__catch$?GenerateData@?$ImageFileReader at V?$Image at F$02 at itk
@@V?$DefaultConvertPixelTraits at F@2@@itk@@MAEXXZ$0
1>HelloWorld.obj : error LNK2019: unresolved external symbol "public:
__thiscall itk::ImageIORegion::ImageIORegion(class itk::ImageIORegion const
&)" (??0ImageIORegion at itk@@QAE at ABV01@@Z) referenced in function
__catch$?GenerateData@?$ImageFileReader at V?$Image at F$02 at itk
@@V?$DefaultConvertPixelTraits at F@2@@itk@@MAEXXZ$0
1>HelloWorld.obj : error LNK2019: unresolved external symbol "class
std::basic_ostream<char,struct std::char_traits<char> > & __cdecl
itk::operator<<(class std::basic_ostream<char,struct std::char_traits<char>
> &,class itk::ImageIORegion const &)" (??6itk@@YAAAV?$basic_ostream at DU
?$char_traits at D@std@@@std@@AAV12 at ABVImageIORegion@0@@Z) referenced in
function __catch$?GenerateData@?$ImageFileReader at V?$Image at F$02 at itk
@@V?$DefaultConvertPixelTraits at F@2@@itk@@MAEXXZ$0
1>HelloWorld.obj : error LNK2019: unresolved external symbol "public: void
__thiscall itk::ImageIORegion::SetIndex(unsigned long,long)"
(?SetIndex at ImageIORegion@itk@@QAEXKJ at Z) referenced in function "public:
static void __cdecl itk::ImageIORegionAdaptor<3>::Convert(class
itk::ImageRegion<3> const &,class itk::ImageIORegion &,class itk::Index<3>
const &)" (?Convert@?$ImageIORegionAdaptor@$02 at itk@@SAXABV?$ImageRegion@
$02 at 2@AAVImageIORegion at 2@ABV?$Index@$02 at 2@@Z)
1>HelloWorld.obj : error LNK2019: unresolved external symbol "public: void
__thiscall itk::ImageIORegion::SetSize(unsigned long,unsigned long)"
(?SetSize at ImageIORegion@itk@@QAEXKK at Z) referenced in function "public:
static void __cdecl itk::ImageIORegionAdaptor<3>::Convert(class
itk::ImageRegion<3> const &,class itk::ImageIORegion &,class itk::Index<3>
const &)" (?Convert@?$ImageIORegionAdaptor@$02 at itk@@SAXABV?$ImageRegion@
$02 at 2@AAVImageIORegion at 2@ABV?$Index@$02 at 2@@Z)
1>HelloWorld.obj : error LNK2019: unresolved external symbol "public:
unsigned int __thiscall itk::ImageIORegion::GetImageDimension(void)const "
(?GetImageDimension at ImageIORegion@itk@@QBEIXZ) referenced in function
"public: static void __cdecl itk::ImageIORegionAdaptor<3>::Convert(class
itk::ImageRegion<3> const &,class itk::ImageIORegion &,class itk::Index<3>
const &)" (?Convert@?$ImageIORegionAdaptor@$02 at itk@@SAXABV?$ImageRegion@
$02 at 2@AAVImageIORegion at 2@ABV?$Index@$02 at 2@@Z)
1>HelloWorld.obj : error LNK2019: unresolved external symbol "public: long
__thiscall itk::ImageIORegion::GetIndex(unsigned long)const "
(?GetIndex at ImageIORegion@itk@@QBEJK at Z) referenced in function "public:
static void __cdecl itk::ImageIORegionAdaptor<3>::Convert(class
itk::ImageIORegion const &,class itk::ImageRegion<3> &,class itk::Index<3>
const &)" (?Convert@?$ImageIORegionAdaptor@$02 at itk@@SAXABVImageIORegion at 2
@AAV?$ImageRegion@$02 at 2@ABV?$Index@$02 at 2@@Z)
1>HelloWorld.obj : error LNK2019: unresolved external symbol "public:
unsigned long __thiscall itk::ImageIORegion::GetSize(unsigned long)const "
(?GetSize at ImageIORegion@itk@@QBEKK at Z) referenced in function "public: static
void __cdecl itk::ImageIORegionAdaptor<3>::Convert(class itk::ImageIORegion
const &,class itk::ImageRegion<3> &,class itk::Index<3> const &)" (?Convert@
?$ImageIORegionAdaptor@$02 at itk@@SAXABVImageIORegion at 2@AAV?$ImageRegion@$02 at 2
@ABV?$Index@$02 at 2@@Z)
1>HelloWorld.obj : error LNK2019: unresolved external symbol "public: class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > __thiscall
itk::ImageIOBase::GetComponentTypeAsString(enum
itk::ImageIOBase::IOComponentType)const "
(?GetComponentTypeAsString at ImageIOBase@itk@@QBE?AV?$basic_string at DU
?$char_traits at D@std@@V?$allocator at D@2@@std@@W4IOComponentType at 12@@Z)
referenced in function "protected: void __thiscall
itk::ImageFileReader<class itk::Image<short,3>,class
itk::DefaultConvertPixelTraits<short> >::DoConvertBuffer(void *,unsigned
long)" (?DoConvertBuffer@?$ImageFileReader at V?$Image at F$02 at itk
@@V?$DefaultConvertPixelTraits at F@2@@itk@@IAEXPAXK at Z)



This is the content of the CMakeLists.txt file:

# This is the root ITK CMakeLists file.
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
IF(COMMAND CMAKE_POLICY)
  CMAKE_POLICY(SET CMP0003 NEW)
ENDIF(COMMAND CMAKE_POLICY)


# This project is designed to be built outside the Insight source tree.
PROJECT(HelloWorld)

# Find ITK.
FIND_PACKAGE(ITK REQUIRED)
INCLUDE(${ITK_USE_FILE})

ADD_EXECUTABLE(HelloWorld HelloWorld.cxx )

TARGET_LINK_LIBRARIES(HelloWorld ITKCommon)


Do I need to add some LINK_DIRECTORIES ?


On Wed, Jun 10, 2009 at 11:26 AM, Mathieu Malaterre <
mathieu.malaterre at gmail.com> wrote:

> On Tue, Jun 9, 2009 at 10:56 PM, motes motes<mort.motes at gmail.com> wrote:
> > I have a .dcm file containing multiple frames. I need to downsample each
> > frame and store them in a new and smaller .dcm file. Currently I use
> matlab
> > for the first part:
> >
> > for i=1: frameNum
> >   img0 = dicomread(filename, 'frames', i)
> >   img1 =  downsample(img0);
> >   %dicomwrite(img1, 'test.dcm')
> >   % store img1....
> > end
> >
> > But it seems that its only possible to store each frame as a separate
> file -
> > and not as a single multiframe .dcm file.
> >
> > I was therefore wondering if ITK had any functionality to make this
> > possible? I found this post:
> >
> > http://www.itk.org/pipermail/insight-users/2003-September/004762.html
> >
> > and the file itkDICOMImageSeriesTest.cxx in:
> >
> > InsightToolkit-3.12.0\Testing\Code\IO
> >
> > But maybe there are some more documentation on how to do this?
> >
>
> Yes.
> 7.12.3 Reading a 2D DICOM Series and Writing a Volume (from
> ItkSoftwareGuide.pdf).
>
> Please do not cross post to dicom newsgroup for a matlab function, thanks.
>
> 2cts.
> --
> Mathieu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090610/c722db63/attachment-0001.htm>


More information about the Insight-users mailing list