[Insight-users] CastImageFilter error

akbarjan bayiz abayiz at yahoo.com
Mon Mar 21 04:40:07 EDT 2011


Hello!

Thank you very much for your reply. 

Sorry for forgetting the FixedImageType in my previous example. It should be like:
const unsigned int Dimension = 3;
typedef unsigned short PixelType;
typedef itk::Image< PixelType, Dimension >  FixedImageType;

Actually, my code is too long, that is why I just included the error part, here is error part of my code and CMakeLists.txt : 

***************************************
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif

#ifdef __BORLANDC__
#define ITK_LEAN_AND_MEAN
#endif


#define HAVE_CONFIG_H 1 
#include <osconfig.h>

#include <iostream>
#include <fstream>
#include <sstream>
#include <cstring>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include "BaseData.h"
#include "vtkImageCast.h"
#include "./Headerfiles/itkVTKImageToImageFilter.h"
#include "itkCastImageFilter.h"
#include "itkImage.h"
#include "itkVector.h"
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkCastImageFilter.h"
#include "DICOMLoader.h"
#include "ContentTree.h"
#include "ContentItem.h"
#include "itkImageToVTKImageFilter.h"

const unsigned int Dimension = 3;
typedef unsigned short PixelType;
typedef itk::Image< float, 3 >  InternalImageType;
typedef itk::Image< float, 3 > ImageType;
typedef itk::VTKImageToImageFilter<ImageType> VTKImageToImageType;
typedef itk::Image< PixelType, Dimension >  FixedImageType;

using namespace std;

int main( int argc, char * argv[] )
{
    Vav::Loader::DICOMLoader* fixedImageLoader = new Vav::Loader::DICOMLoader();
    Vav::Data::BaseData*    fixedImageData= new Vav::Data::BaseData();
    ContentTree *fixedImageTree;
    ContentItem* fixedImageItem;

    fixedImageTree=NULL;
    fixedImageTree = fixedImageLoader->LoadDataContent(argv[1]);
    fixedImageData = fixedImageLoader->LoadData(fixedImageItem);

   vtkImageCast* VtkCasterFixed = vtkImageCast::New(); // Casting to float in VTK is needed
   VtkCasterFixed->SetInput(fixedImageData -> GetScalar() -> GetImageData());
   VtkCasterFixed->SetOutputScalarTypeToFloat();
   VTKImageToImageType::Pointer reader = VTKImageToImageType::New();
   reader->SetInput( VtkCasterFixed->GetOutput());
   reader->GetImporter()->Update();

  typedef float InternalPixelType;
  typedef itk::Image< InternalPixelType, Dimension > InternalImageType;
  typedef itk::CastImageFilter< FixedImageType, InternalImageType > CasterType;

  CasterType::Pointer Caster   = CasterType::New();
  Caster->SetInput( reader->GetOutput() );

}
*******************************
And the CMakeLists.txt is as follows:
***********************************
cmake_minimum_required(VERSION 2.6)
 
PROJECT(Registration)

include_directories(/home/Desktop/ITK/Registration/Headerfiles/)
include_directories(/home/Desktop/ITK/Registration/Data/)
include_directories(/home/Desktop/ITK/Registration/Loader/)
include_directories(/usr/include/dcmtk/config)
include_directories(/usr/include/dcmtk/ofstd)
include_directories(/usr/include/dcmtk/dcmdata)
include_directories(/usr/include/dcmtk/dcmtls)
include_directories(/usr/include/dcmtk/dcmsr)
include_directories(/usr/include/dcmtk/dcmnet)
include_directories(/usr/include/dcmtk/dcmstat)
include_directories(/usr/include/dcmtk/dcmimage)
include_directories(/usr/include/dcmtk/dcmimgle)
include_directories(/usr/include/dcmtk/dcmqrdb)
include_directories(/usr/include/dcmtk/dcmwlm)
include_directories(/usr/local/dcmtk-3.5.4/lib)
include_directories(/usr/include/dcmtk/dcmsign)
include_directories(/opt/qtsdk-2010.04/qt/include/QtUiTools)
include_directories(/home/Desktop/InsightToolkit-3.20.0/Wrapping/WrapITK/ExternalProjects/ItkVtkGlue/src/)
include_directories(/home/Desktop/InsightToolkit-3.20.0/Utilities/KWStyle)
 
FIND_PACKAGE(ITK REQUIRED)
INCLUDE(${ITK_USE_FILE})
 
FIND_PACKAGE(VTK REQUIRED)
INCLUDE(${VTK_USE_FILE})

FIND_PACKAGE(DCMTK REQUIRED)
ADD_EXECUTABLE(Demons Demons.cxx) 

TARGET_LINK_LIBRARIES(Demons ITKIO ITKNumerics ITKStatistics  
 ITKCommon ITKBasicFilters 
vtkIO vtkFiltering
vtkImaging VavFrame
${QT_LIBRARIES}
 ssl mysqlclient  ${DCMTK_LIBRARIES} 
dcmnet dcmdsig dcmqrdb dcmwlm dcmsr dcmjpeg dcmimage dcmimgle dcmpstat ijg8 
ijg12 ijg16 dcmtls dcmdata ofstd z xml2 tiff itpp wrap ofstd QtSql
 ${ITK_LIBRARIES})

**************************************

Hope to receive any help soon! 
Thank you very much in advance! 

Best regards,



--- On Mon, 3/21/11, Dan Mueller <dan.muel at gmail.com> wrote:

> From: Dan Mueller <dan.muel at gmail.com>
> Subject: Re: [Insight-users] CastImageFilter error
> To: "akbarjan bayiz" <abayiz at yahoo.com>
> Cc: insight-users at itk.org
> Date: Monday, March 21, 2011, 12:13 AM
> Hi,
> 
> We miss the definition of FixedImageType in your mail. Is
> FixedImageType the same as VTKImageToImageType?
> 
> I recommend sending to the mailing list a minimal example
> (complete
> source code which isolates the problem and CMakeLists.txt).
> I figure
> in your case a minimal example should be 10-15 lines of
> code. Doing so
> will help those on the mailing list reproduce your issue
> with the
> least amount of effort.
> 
> Regards, Dan
> 
> On 20 March 2011 20:40, akbarjan bayiz <abayiz at yahoo.com>
> wrote:
> > Hello all!
> >
> > I am trying to convert data from one type to another
> using following lines in ITK:
> >
> > ********************************
> > const unsigned int Dimension = 3;
> > typedef itk::Image< float, 3 > ImageType;
> > typedef itk::VTKImageToImageFilter<ImageType>
> VTKImageToImageType;
> >
> >
> > VTKImageToImageType::Pointer reader =
> VTKImageToImageType::New();
> > ...
> > ........................
> >
> > typedef float InternalPixelType;
> > typedef itk::Image< InternalPixelType, Dimension
> > InternalImageType;
> > typedef itk::CastImageFilter< FixedImageType,
> InternalImageType > CasterType;
> >
> > CasterType::Pointer Caster   = CasterType::New();
> > Caster->SetInput( reader->GetOutput() );
> > ****************
> >
> > And it gives out the following error message:
> > "no matching function for call to
> ‘itk::CastImageFilter<itk::Image<short unsigned int,
> 3u>, itk::Image<float, 3u> >::SetInput(const
> itk::Image<float, 3u>*) "
> >
> > I have been working for this for about one week, and
> cannot figure it out yet. I really hope someone could help
> me... many warm thanks in advance!
> >
> >
> >
> > _____________________________________
> > 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.html
> >
> > 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://www.itk.org/mailman/listinfo/insight-users
> >
>



      


More information about the Insight-users mailing list