From f4345fcbbb606af15d5af72b6179d5103ff75565 Mon Sep 17 00:00:00 2001 From: davila Date: Wed, 15 Oct 2014 17:16:56 +0200 Subject: [PATCH] #2458 creaImageIO Feature New Normal - UnMosaic Images SimpleView Gimick --- src/creaImageIOGimmickView.cpp | 64 ++++++++++++++++++---------------- src/creaImageIOSimpleView.cpp | 27 +++++++++++--- src/creaImageIOSimpleView.h | 13 +++++-- src/creaImageIOWxSimpleDlg.cpp | 4 +-- 4 files changed, 70 insertions(+), 38 deletions(-) diff --git a/src/creaImageIOGimmickView.cpp b/src/creaImageIOGimmickView.cpp index 0a76936..0281042 100644 --- a/src/creaImageIOGimmickView.cpp +++ b/src/creaImageIOGimmickView.cpp @@ -486,20 +486,37 @@ void GimmickView::ReadImagesNotThreaded(std::vector& s, std::vect void GimmickView::readImages1(std::vector& o_output, std::vector im, OutputAttr i_attr) { + + i_attr.outside.push_back("D0019_100a"); // simens Number Of Images In Mosaic + +//EED Borrame + int i,isize=i_attr.outside.size(); + for (i=0;i::iterator it; for (it=im.begin(); it!=im.end(); ++it) { OutStrGimmick out; out.img = vtkImageData::New(); out.img->ShallowCopy(mReader.GetImage(*it)); - if(i_attr.mult) +printf("EED GimmickView::readImages1 A\n "); + if(i_attr.mult) + { getAttributes((*it),out.infos,i_attr); +printf("EED GimmickView::readImages1 B %s \n ", out.infos.find("D0019_100a")->second.c_str() ); + } o_output.push_back(out); } // If we want only one output information structure, we set it outside the loop if(!i_attr.mult) { getAttributes(im.front(), o_output.front().infos, i_attr); +printf("EED GimmickView::readImages1 C %s \n ", o_output.front().infos.find("D0019_100a")->second.c_str() ); } } @@ -520,9 +537,7 @@ void GimmickView::ReadImagesNotThreaded(std::vector& s, std::vect if(ext[5] == 0) { ext[5] = (int)im.size()-1; - } - else - { + } else { ext[5] = ext[5] * (int)im.size()-1; // to deal with multiframes } out.img->SetExtent(ext); @@ -665,19 +680,15 @@ void GimmickView::ReadImagesNotThreaded(std::vector& s, std::vect if ( size == 0) { return; - } - else if (size == 1) - { + } else if (size == 1) { // Simplest case // Only one image : give it // But take in count multiframe possibility if ( isSingle(im.front()) || i_dim != 1) { readImages1(o_output,im, i_attr); - } - else - { - readImages2(o_output,im, i_attr,i_zspc); + } else { + readImages2(o_output,im, i_attr,i_zspc); } } else { // multiple or single frame @@ -688,40 +699,33 @@ void GimmickView::ReadImagesNotThreaded(std::vector& s, std::vect { // 2D to 3D readImages3(o_output,im, i_attr,i_zspc); - } - else - { + } else { readImages1(o_output,im, i_attr); } - } - else - { + } else { // we deal with multiple frames n x (2D x T) // Differents outputs are avaialable if(i_dim == 1) { // put all in one output readImages3(o_output,im, i_attr,i_zspc); - - } - else if( i_dim == 2) - { + } else if( i_dim == 2) { // put in a vector of n x T (2D) readImages2(o_output,im, i_attr,i_zspc); - } - else if( i_dim == 3) - { + } else if( i_dim == 3) { // put in a vector of n (2D x T) // No transformations. readImages1(o_output,im, i_attr); - } - else - { + } else { // put in a vector of T (2D x n) readImages4(o_output,im, i_attr); - } - } - } + } // i_dim + } //isSingle(im.front()) + } // if size + +//EED UnMosaic step... +//How to verifie if is a mosaic file , with how many images inside?? + } diff --git a/src/creaImageIOSimpleView.cpp b/src/creaImageIOSimpleView.cpp index 0192143..96d0e74 100644 --- a/src/creaImageIOSimpleView.cpp +++ b/src/creaImageIOSimpleView.cpp @@ -32,7 +32,10 @@ namespace creaImageIO { - bool SimpleView::readFile(std::vector i_filenames, std::vector &i_img) + bool SimpleView::readFile( std::vector i_filenames, // in information names + std::vector i_attr, // in information attributes names + std::vector > &i_imgAttr, // out information attributes names-values + std::vector &i_img) // out information vtkImageData { bool bresult, bfinal = true; ImageReader *mReader = new ImageReader(); @@ -42,7 +45,13 @@ namespace creaImageIO bresult = mReader->CanRead((*it).c_str()); if(bresult) { - i_img.push_back(mReader->ReadImage((*it).c_str())); + std::map mapAttr; + mReader->getAttributes( (*it).c_str() , mapAttr, i_attr ); // filename, outMapAttr-NameValue, inVectAttributeName + i_imgAttr.push_back( mapAttr ); + + //UnMosaic step.. + + i_img.push_back( mReader->ReadImage( (*it).c_str() ) ); } else { printf("ERROR. Impossible to read file %s\n", (*it).c_str() ); bfinal = false; @@ -53,7 +62,10 @@ namespace creaImageIO } - bool SimpleView::readDirectory(const std::string i_pathname, std::vector &i_imgs) + bool SimpleView::readDirectory( const std::string i_pathname, // in information names + std::vector i_attr, // in information attributes names + std::vector > &i_imgAttr, // out information attributes names-values + std::vector &i_imgs) // out information vtkImageData { bool bresult = true; ImageReader *mReader = new ImageReader(); @@ -78,7 +90,14 @@ namespace creaImageIO for(int i=0; i mapAttr; + mReader->getAttributes( names[i] , mapAttr, i_attr ); // filename, outMapAttr-NameValue, inVectAttributeName + i_imgAttr.push_back( mapAttr ); + + //UnMosaic step.. + i_imgs.push_back( mReader->ReadImage(names[i]) ); } } diff --git a/src/creaImageIOSimpleView.h b/src/creaImageIOSimpleView.h index 25cff51..669af13 100644 --- a/src/creaImageIOSimpleView.h +++ b/src/creaImageIOSimpleView.h @@ -48,10 +48,19 @@ namespace creaImageIO ~SimpleView(){} /// read file(s) and return a vector of vtkImageData - bool readFile( std::vector i_filenames, std::vector< vtkImageData *> &i_img); + bool readFile( std::vector i_filenames, // in information names + std::vector i_attr, // in information attributes names + std::vector > &i_imgAttr, // out information attributes names-values + std::vector< vtkImageData *> &i_img); // out information vtkImageData /// read a directory and return a vector of vtkImageData - bool readDirectory(const std::string i_pathname, std::vector< vtkImageData *> &i_imgs); + bool readDirectory( const std::string i_pathname, // in information names + std::vector i_attr, // in information attributes names + std::vector > &i_imgAttr, // out information attributes names-values + std::vector &i_imgs); // out information vtkImageData + + + }; } diff --git a/src/creaImageIOWxSimpleDlg.cpp b/src/creaImageIOWxSimpleDlg.cpp index a537b32..5d05322 100644 --- a/src/creaImageIOWxSimpleDlg.cpp +++ b/src/creaImageIOWxSimpleDlg.cpp @@ -85,7 +85,7 @@ namespace creaImageIO { files.push_back( crea::wx2std(wxArray[i])); } - if(!m_view.readFile(files,m_results)) + if( !m_view.readFile(files , m_attrDicomTags , m_resultsDicomAtr , m_results) ) { //TO DO WARNING MESSAGE; } @@ -113,7 +113,7 @@ namespace creaImageIO { m_results.clear(); infoimage=_T("DIRECTORY:")+dirDlg->GetPath(); - if(! m_view.readDirectory(crea::wx2std(dirDlg->GetPath()),m_results)) + if(! m_view.readDirectory(crea::wx2std(dirDlg->GetPath()) , m_attrDicomTags , m_resultsDicomAtr , m_results)) { //TO DO WARNING MESSAGE; } -- 2.44.0