From: Eduardo DAVILA Date: Tue, 5 Sep 2017 11:57:18 +0000 (+0200) Subject: #3123creaImageIO Bug New Normal - branch changestoITK3and4 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=14867d130e020e6d8141aff67ef735c1a8e50011;p=creaImageIO.git #3123creaImageIO Bug New Normal - branch changestoITK3and4 --- diff --git a/bbtk/src/bbcreaImageIOItkImagesChooserDialogBox.cxx b/bbtk/src/bbcreaImageIOItkImagesChooserDialogBox.cxx index 434b719..e0c2a1e 100644 --- a/bbtk/src/bbcreaImageIOItkImagesChooserDialogBox.cxx +++ b/bbtk/src/bbcreaImageIOItkImagesChooserDialogBox.cxx @@ -119,14 +119,10 @@ template void ItkImagesChooserDialogBox::Export() { typedef itk::Image TImage; - -printf("EED ItkImagesChooserDialogBox::Export Start \n"); if (dlg->getImagesSelected().size() == 1) { -printf("EED ItkImagesChooserDialogBox::Export 1\n"); bbSetOutputOut( dlg->getTemplatedImagesSelected().front().GetPointer() ); } else if (dlg->getImagesSelected().size() > 1){ -printf("EED ItkImagesChooserDialogBox::Export 2\n"); OutputImagesITKType outVect; typename std::vector tempImgs= dlg->getTemplatedImagesSelected(); typename std::vector::iterator it = tempImgs.begin(); @@ -136,25 +132,14 @@ printf("EED ItkImagesChooserDialogBox::Export 2\n"); } // for bbSetOutputOutIImages( outVect); -//EED creater one 3D image from 2D list -// const unsigned int Dimension = 3; -// typedef itk::RGBPixel< unsigned char > RGBPixelType; -// typedef itk::Image< RGBPixelType, Dimension > RGBImageType; -// typedef itk::ImportImageFilter< RGBPixelType, Dimension > ImportFilterType; - -// typedef itk::RGBPixel< ty > RGBPixelType; typedef ty RGBPixelType; typedef itk::ImportImageFilter< ty , di > ImportFilterType; - typename ImportFilterType::Pointer importFilter = ImportFilterType::New(); - + typename ImportFilterType::Pointer importFilter = ImportFilterType::New(); typename TImage::SizeType imsize; -// imsize[0] = img.width(); -// imsize[1] = img.height(); imsize[0] = tempImgs[0].GetPointer()->GetLargestPossibleRegion().GetSize()[0]; imsize[1] = tempImgs[0].GetPointer()->GetLargestPossibleRegion().GetSize()[1]; imsize[2] = tempImgs.size(); -printf("EED ItkImagesChooserDialogBox::Export 2.10\n"); typename ImportFilterType::IndexType start; start.Fill( 0 ); @@ -163,65 +148,42 @@ printf("EED ItkImagesChooserDialogBox::Export 2.10\n"); region.SetSize( imsize ); importFilter->SetRegion( region ); -// const itk::SpacePrecisionType origin[ di ] = { 0.0, 0.0, 0.0 }; const itk::SpacePrecisionType origin[ 3 ] = { 0.0, 0.0, 0.0 }; importFilter->SetOrigin( origin ); -// const itk::SpacePrecisionType spacing[ di ] = { 1.0, 1.0, 1.0 }; const itk::SpacePrecisionType spacing[ 3 ] = { 1.0, 1.0, 1.0 }; importFilter->SetSpacing( spacing ); - const unsigned long int numberOfPixels2D = imsize[0]*imsize[1]; - const unsigned long int numberOfPixels3D = imsize[0]*imsize[1]*imsize[2]; + const unsigned long int numberOfPixels2D = imsize[0]*imsize[1]; + const unsigned long int numberOfPixels2DInBytes = imsize[0]*imsize[1]*sizeof(ty); + const unsigned long int numberOfPixels3D = imsize[0]*imsize[1]*imsize[2]*sizeof(ty); - RGBPixelType * localBuffer = new RGBPixelType[ numberOfPixels3D ]; + RGBPixelType * localBuffer = new RGBPixelType[ numberOfPixels3D ]; RGBPixelType * tmpLocalBuffer = localBuffer; -printf("EED ItkImagesChooserDialogBox::Export 2.20\n"); it = tempImgs.begin(); for(;it != tempImgs.end(); ++it) { -printf("EED ItkImagesChooserDialogBox::Export 2.30\n"); - memcpy(tmpLocalBuffer, (*it).GetPointer()->GetBufferPointer(), numberOfPixels2D); + memcpy(tmpLocalBuffer, (*it).GetPointer()->GetBufferPointer(), numberOfPixels2DInBytes); tmpLocalBuffer = tmpLocalBuffer + numberOfPixels2D; } // for const bool importImageFilterWillOwnTheBuffer = true; importFilter->SetImportPointer( localBuffer , numberOfPixels3D , importImageFilterWillOwnTheBuffer ); -importFilter->Update(); -importFilter->Register(); -printf("EED ItkImagesChooserDialogBox::Export 2.40\n"); - -// bbSetOutputOut( (*tempImgs.begin()).GetPointer() ); -// bbSetOutputOut( importFilter->GetOutput().unsafe_get() ); + importFilter->Update(); + importFilter->Register(); bbSetOutputOut( importFilter->GetOutput() ); -printf("EED ItkImagesChooserDialogBox::Export 2.50\n"); } else { -printf("EED ItkImagesChooserDialogBox::Export 3\n"); // warning: passing NULL to non-pointer //bbSetOutputOut( NULL); bbSetOutputOut(0); // JPR } - // FCY To test the Output - //typedef itk::Image ImageType; - //typedef itk::ImageFileReader< ImageType > itkReaderType; - // typename itkReaderType::Pointer reader = itkReaderType::New(); - // - // reader->SetFileName("d:\test.hdr"); - // reader->Update(); - //reader->GetOutput()->Register(); - // this->bbSetOutputOut(reader->GetOutput()); - -printf("EED ItkImagesChooserDialogBox::Export End \n"); - } template void ItkImagesChooserDialogBox::ExportVTK() { -printf("EED ItkImagesChooserDialogBox::ExportVTK Start \n"); - // BBTK can support only a vector with same dimensions image. if (dlg->getDims().front() < 4) { @@ -239,7 +201,6 @@ printf("EED ItkImagesChooserDialogBox::ExportVTK Start \n"); } else { // NOT IMPLEMENTED YET FOR DIMENSIONS > 4 } // if dlg -printf("EED ItkImagesChooserDialogBox::ExportVTK End \n"); } //===== diff --git a/src/creaImageIOWxAnySimpleDlg.cpp b/src/creaImageIOWxAnySimpleDlg.cpp index 11d5fa9..a8db5f7 100644 --- a/src/creaImageIOWxAnySimpleDlg.cpp +++ b/src/creaImageIOWxAnySimpleDlg.cpp @@ -132,7 +132,6 @@ namespace creaImageIO ////////////////////////////////////////////////////////////////////// void WxAnySimpleDlg::OnReadDirectory(wxCommandEvent &event) { -printf("EED WxAnySimpleDlg::OnReadDirectory Start\n"); int resultShowModal; bool bvalid = false; long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST; @@ -142,7 +141,6 @@ printf("EED WxAnySimpleDlg::OnReadDirectory Start\n"); if ( resultShowModal==wxID_OK ) { std::string path = crea::wx2std(dirDlg->GetPath()); -printf("EED WxAnySimpleDlg::OnReadDirectory path %s\n", path.c_str() ); /* typedef boost::filesystem::directory_iterator dir_it; @@ -182,8 +180,7 @@ printf("EED WxAnySimpleDlg::OnReadDirectory Each file %s \n", itr->path().strin for (vec::const_iterator it (v.begin()); it != v.end(); ++it) { readImg( it->string().c_str() ); - cout << " " << *it << '\n'; - } + } // for @@ -192,7 +189,6 @@ printf("EED WxAnySimpleDlg::OnReadDirectory Each file %s \n", itr->path().strin SetReturnCode( resultShowModal ); // Close(); EndModal( resultShowModal ); -printf("EED WxAnySimpleDlg::OnReadDirectory End\n"); } @@ -270,8 +266,6 @@ printf("EED WxAnySimpleDlg::OnReadDirectory End\n"); { size_t dims = getNumberOfDimensions(i_name); -printf("EED WxAnySimpleDlg::readImg dims=%d \n",dims); - //const std::type_info *type= &getType(i_name); switch(dims) {