-//=====
+ //=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
#include "bbcreaVtkFromVtk4DToItk4D.h"
#include "bbcreaVtkPackage.h"
-#include "creaVtkFromVtk4DToItk4D.h"
+
#include "vtkImageData.h"
#include "itkImage.h"
+
namespace bbcreaVtk
{
//=====
void FromVtk4DToItk4D::Process()
{
- creaVtkFromVtk4DToItk4D<vtkImageData*> prs;
+printf("EED FromVtk4DToItk4D::Process 1\n ");
+//EED creaVtkFromVtk4DToItk4D<vtkImageData*> prs;
+ creaVtkFromVtk4DToItk4D prs;
+printf("EED FromVtk4DToItk4D::Process 2\n ");
prs.SetImage4Dvtk(bbGetInputIn());
- //Bug. Cant declare output image in .h
- //bbSetOutputOut(prs.Process());
+printf("EED FromVtk4DToItk4D::Process 3\n ");
+ //CT Bug. Cant declare output image in .h
+ prs.Process();
+//EED bbSetOutputOut( );
}
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
#include "bbcreaVtk_EXPORT.h"
#include "bbtkAtomicBlackBox.h"
#include "iostream"
+
#include "vtkImageData.h"
#include <vector>
-#include "itkImage.h"
+//#include "itkImage.h"
+#include "creaVtkFromVtk4DToItk4D.h"
namespace bbcreaVtk
{
public bbtk::AtomicBlackBox
{
BBTK_BLACK_BOX_INTERFACE(FromVtk4DToItk4D,bbtk::AtomicBlackBox);
-
BBTK_DECLARE_INPUT(In,std::vector<vtkImageData*> );
- //Bug. Image type doesn't work.
- //BBTK_DECLARE_OUTPUT(Out,std::vector<itk::Image< unsigned char > >);
+ BBTK_DECLARE_OUTPUT(Out, Image4DType::Pointer );
BBTK_PROCESS(Process);
void Process();
};
BBTK_BEGIN_DESCRIBE_BLACK_BOX(FromVtk4DToItk4D,bbtk::AtomicBlackBox);
-BBTK_NAME("FromVtk4DToItk4D");
-BBTK_AUTHOR("Carlos Torres");
-BBTK_DESCRIPTION("carlos.torres@creatis.insa-lyon.fr -");
-BBTK_CATEGORY("empty");
-BBTK_INPUT(FromVtk4DToItk4D,In,"Vtk image 4D",std::vector<vtkImageData*>,"");
-//BBTK_OUTPUT(FromVtk4DToItk4D,Out,"Itk image 4D",std::vector<itk::Image< unsigned char > >,"");
+ BBTK_NAME("FromVtk4DToItk4D");
+ BBTK_AUTHOR("Carlos Torres");
+ BBTK_DESCRIPTION("carlos.torres@creatis.insa-lyon.fr -");
+ BBTK_CATEGORY("empty");
+
+ BBTK_INPUT(FromVtk4DToItk4D,In,"Vtk image 4D",std::vector<vtkImageData*>,"");
+
+ BBTK_OUTPUT(FromVtk4DToItk4D,Out,"Itk image 4D", Image4DType::Pointer ,"");
+
BBTK_END_DESCRIBE_BLACK_BOX(FromVtk4DToItk4D);
}
*/
#include "creaVtkFromVtk4DToItk4D.h"
-#include "itkImage.h"
-#include "itkImageLinearConstIteratorWithIndex.h"
-#include "itkImageRegionConstIterator.h"
+//#include "itkImage.h"
+
+//#include <itkImageRegionConstIteratorWithIndex.h>
+
+
+//#include "itkImageRegionConstIterator.h"
#include "itkImageRegionIterator.h"
-#include "itkImageFileReader.h"
+// #include "itkImageFileReader.h"
#include <vector>
-template <class TImage>
-creaVtkFromVtk4DToItk4D<TImage>::creaVtkFromVtk4DToItk4D()
+//template <class TImage>
+//creaVtkFromVtk4DToItk4D<TImage>::creaVtkFromVtk4DToItk4D()
+creaVtkFromVtk4DToItk4D::creaVtkFromVtk4DToItk4D()
{
}
-template <class TImage>
-creaVtkFromVtk4DToItk4D<TImage>::~creaVtkFromVtk4DToItk4D()
+//EED template <class TImage>
+//EED creaVtkFromVtk4DToItk4D<TImage>::~creaVtkFromVtk4DToItk4D()
+creaVtkFromVtk4DToItk4D::~creaVtkFromVtk4DToItk4D()
{
}
-template <class TImage>
-void creaVtkFromVtk4DToItk4D<TImage>::SetImage4D(TImage *image)
+//EED template <class TImage>
+//EED void creaVtkFromVtk4DToItk4D<TImage>::SetImage4D(TImage *image)
+//EED {
+//EED _image4D = image;
+//EED }
+
+
+Image4DType::Pointer creaVtkFromVtk4DToItk4D::GetResult()
{
- _image4D = image;
+ return _image4D;
}
-template <class TImage>
-void creaVtkFromVtk4DToItk4D<TImage>::SetImage4Dvtk(std::vector<vtkImageData*> image)
+
+//EED template <class TImage>
+//EED void creaVtkFromVtk4DToItk4D<TImage>::SetImage4Dvtk( std::vector<vtkImageData*> image)
+void creaVtkFromVtk4DToItk4D::SetImage4Dvtk( std::vector<vtkImageData*> image)
{
- image4Dvtk = image;
+ _image4Dvtk = image;
}
-template <class TImage>
-std::vector<itk::Image< unsigned char > > creaVtkFromVtk4DToItk4D<TImage>::Process()
+//EED template <class TImage>
+//EED std::vector<itk::Image< unsigned char > > creaVtkFromVtk4DToItk4D<TImage>::Process()
+void creaVtkFromVtk4DToItk4D::Process()
{
/*
int dir;
}
}
*/
- const unsigned int Dimension = 4;
+
+
+/* EED2
+ const unsigned int Dimension = 4;
typedef unsigned char PixelType;
typedef itk::Image< PixelType, Dimension > ImageType;
typedef itk::ImageRegionConstIterator< ImageType > ConstIteratorType;
outputStart[3] = 0;
outputRegion.SetSize( size );
outputRegion.SetIndex( outputStart );
+*/
/*
ReaderType::Pointer reader = ReaderType::New();
<< reader->GetOutput()->GetRequestedRegion() << std::endl;
return -1;
}*/
+
+
+
+/* EED
std::vector<ImageType::Pointer> outputImage4D;
- for(int k = 0 ; k < image4Dvtk.size() ; k++){
+ for(int k = 0 ; k < _image4Dvtk.size() ; k++)
+ {
ImageType::Pointer outputImage = ImageType::New();
outputImage->SetRegions( outputRegion );
- const ImageType::SpacingType& spacing = image4Dvtk[k]->GetSpacing();
- const ImageType::PointType& inputOrigin = image4Dvtk[k]->GetOrigin();
+ const ImageType::SpacingType& spacing = _image4Dvtk[k]->GetSpacing();
+ const ImageType::PointType& inputOrigin = _image4Dvtk[k]->GetOrigin();
double outputOrigin[ Dimension ];
for(unsigned int i=0; i< Dimension; i++)
- {
+ {
outputOrigin[i] = inputOrigin[i] + spacing[i] * inputStart[i];
- }
+ } // for
outputImage->SetSpacing( spacing );
outputImage->SetOrigin( outputOrigin );
outputImage->Allocate();
- ConstIteratorType inputIt( image4Dvtk[k], inputRegion );
+ ConstIteratorType inputIt( _image4Dvtk[k], inputRegion );
IteratorType outputIt( outputImage, outputRegion );
inputIt.GoToBegin();
outputIt.GoToBegin();
while( !outputIt.IsAtEnd() )
- {
+ {
outputIt.Set( inputIt.Get() );
++inputIt;
++outputIt;
- }
- outputImage4D[k]=outputImage;
+ } // while
+//EED outputImage4D[k]=outputImage;
+ } // for k
+//EED return outputImage4D;
+
+*/
+
+
+
+// http://www.itk.org/pipermail/insight-users/2003-December/005796.html
+// http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/InvertIntensityImageFilter
+
+
+ int ext[6];
+ int dimX, dimY, dimZ;
+ long int sizeimage;
+ unsigned int k, i;
+
+ _image4Dvtk[0]->GetWholeExtent(ext);
+ dimX = ext[1]-ext[0]+1;
+ dimY = ext[3]-ext[2]+1;
+ dimZ = ext[5]-ext[4]+1;
+ sizeimage = dimX*dimY*dimZ;
+
+
+
+ typedef itk::ImageRegionIterator< Image4DType > Iterator4D;
+// typedef itk::ImageRegionConstIterator< Image4DType > Iterator4D;
+// typedef itk::ImageRegionConstIteratorWithIndex< Image4DType > Iterator4D;
+
+
+ _image4D = Image4DType::New();
+
+ Image4DType::RegionType region;
+ Image4DType::IndexType start;
+ start[0] = 0;
+ start[1] = 0;
+ start[2] = 0;
+ start[3] = 0;
+
+ Image4DType::SizeType size;
+ unsigned int NumRows = dimX;
+ unsigned int NumCols = dimY;
+ unsigned int NumSlices = dimZ;
+ unsigned int NumVolumes = _image4Dvtk.size();
+ size[0] = NumRows;
+ size[1] = NumCols;
+ size[2] = NumSlices;
+ size[3] = NumVolumes;
+
+ region.SetSize(size);
+ region.SetIndex(start);
+
+ _image4D->SetRegions(region);
+ _image4D->Allocate();
+
+
+// Iterator4D it4( image4D, image4D->GetBufferedRegion() );
+ Iterator4D it4( _image4D, _image4D->GetLargestPossibleRegion() );
+ it4.GoToBegin();
+ for(k = 0 ; k < _image4Dvtk.size() ; k++)
+ {
+ unsigned short * ptrVtkImage;
+ ptrVtkImage = (unsigned short *)_image4Dvtk[k]->GetScalarPointer();
+ for (i=0; i< sizeimage;i++)
+ {
+ it4.Set( *ptrVtkImage );
+// *it4 = *ptrVtkImage;
+// unsigned short q= it4.Get();
+ ++it4;
+ ptrVtkImage++;
+ }
}
- return outputImage4D;
}
//---------------------------------------------
//Method template
#define _CREAVTKFROMVTK4DTOITK4D_H_
#include "vtkImageData.h"
#include <vector>
+
#include "itkImage.h"
-template <class TImage>
+
+//EED template <class TImage>
+
+typedef unsigned short PixelType;
+typedef itk::Image< PixelType, 4 > Image4DType;
+
class creaVtkFromVtk4DToItk4D
{
public :
creaVtkFromVtk4DToItk4D();
~creaVtkFromVtk4DToItk4D();
- void SetImage4D(TImage *image);
- void SetImage4Dvtk(std::vector<vtkImageData*> image);
- std::vector<itk::Image<unsigned char> > Process();
+//EED void SetImage4D(TImage *image);
+
+ void SetImage4Dvtk(std::vector<vtkImageData*> image);
+//EED std::vector<itk::Image<unsigned char> > Process();
+ void Process();
+ Image4DType::Pointer GetResult();
+
protected:
private:
- TImage* _image4D;
- std::vector<vtkImageData*> image4Dvtk;
+
+//EED TImage* _image4D;
+//EED2 itk::Image<unsigned char> _image4D;
+
+ Image4DType::Pointer _image4D;
+ std::vector<vtkImageData*> _image4Dvtk;
};
+
//-end of _CREAVTKFROMVTK4DTOITK4D_H_------------------------------------------------------
#endif