]> Creatis software - creaImageIO.git/commitdiff
#2842 creaImageIO Bug New Normal - Read images from directory
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Sun, 21 Feb 2016 00:18:52 +0000 (01:18 +0100)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Sun, 21 Feb 2016 00:18:52 +0000 (01:18 +0100)
bbtk/src/bbcreaImageIOImagesChooserDialogBox.xml
src/creaImageIOExternalGimmick.cpp
src/creaImageIOWxSimpleDlg.cpp
src/creaImageIOWxSimpleDlg.h

index 67e768edb96022b095acbb0663625c5edacb1855..816784bbb0cf665f2580a8bc87bd76673026457d 100644 (file)
 
   <process>
     <PRE>
-     
+       
+            
+
         creaImageIO::WxSimpleDlg dlg(0,crea::std2wx(bbGetInputTitle()),"localdatabase_Descriptor.dscp","Local Database"); 
                 dlg.SetAttrDicomTags( bbGetInputDicomTags() );
                dlg.ShowModal(); 
                 bbSetOutputDicomInfo( dlg.getDicomInfoImagesSelected() );
-               if (dlg.getImagesSelected().size()!=0){ 
-                 bbSetOutputFileName( std::string( dlg.getInfoImage().mb_str() ) );
+               if (dlg.getImagesSelected().size()!=0)
+               { 
+                       bbSetOutputFileName( std::string( dlg.getInfoImage().mb_str() ) );
+                       bbSetOutputOut( dlg.getVolumeSelected() );
+               
+/*
                  if(dlg.getImagesSelected().size() ==1)
                  {
                        bbSetOutputOut( dlg.getImagesSelected()[0] );  
                         bbSetOutputOut(first);
                        } // dim
                  }
+*/
+
                } else { 
-               bbSetOutputOut( NULL );  
+                       bbSetOutputOut( NULL );
        } // dlg.getImagesSelected().size()!=0
+
+
+
         bbSetOutputOutImages( dlg.getImagesSelected());  
 printf("EED  creaImageIOWxSimpleDlg 5 \n");
     </PRE>
index 42e07e2fe7fc8605cd92980cc3f55f1116706ed9..f29cf984ae027c319614a18bae3bbd11fae2fa8a 100644 (file)
@@ -39,18 +39,22 @@ vtkImageData* getImageDataDialog()
     std::vector<vtkImageData*> images;
     creaImageIO::WxSimpleDlg w(0,_T("Select your image"),"creaContours_Descriptor.dscp","creatisContours DB");
     w.ShowModal();
+
+    vtkImageData *result=NULL;
+
     if(w.GetReturnCode() == wxID_OK)
     {
-        std::vector<std::string> s;
-        images   = w.getImagesSelected();
-        infoImage = w.getInfoImage();
+//        images         = w.getImagesSelected();
+//        infoImage = w.getInfoImage();
+       result=w.getVolumeSelected();
+
     } // if
 
-    vtkImageData *result=NULL;
-    if (images.size()>0)
-    {
-        result=images[0];
-    }
+// EED 2016/02/16 
+//    if (images.size()>0)
+//    {
+//       result=images[0];
+//    }
 
     return result;
 }
index 5d053226805a45430b51785d2e0af1d1a6e2ecb9..e750b912c185811e58608c261985f64daf97fee4 100644 (file)
@@ -171,6 +171,7 @@ namespace creaImageIO
                 EndModal( dlg.GetReturnCode() );
           }
 
+//-----------------------------------------------------------------------------   
        wxString WxSimpleDlg::getInfoImage()
        {
                return infoimage;
@@ -184,17 +185,108 @@ namespace creaImageIO
                  return m_results;
          }
 
+//-----------------------------------------------------------------------------   
        std::vector< std::map<std::string, std::string> >  WxSimpleDlg::getDicomInfoImagesSelected()
        {
                return m_resultsDicomAtr;
        }
 
+//-----------------------------------------------------------------------------   
        void WxSimpleDlg::SetAttrDicomTags( std::vector<std::string> attr )
        {
                m_attrDicomTags=attr;
        }
          
 
+//-----------------------------------------------------------------------------   
+       vtkImageData*  WxSimpleDlg::getVolumeSelected()
+       {
+               vtkImageData *result;
+
+//        creaImageIO::WxSimpleDlg dlg(0,crea::std2wx(bbGetInputTitle()),"localdatabase_Descriptor.dscp","Local Database"); 
+//             dlg.SetAttrDicomTags( bbGetInputDicomTags() );
+//             dlg.ShowModal(); 
+//             bbSetOutputDicomInfo( dlg.getDicomInfoImagesSelected() );
+
+               if (getImagesSelected().size()!=0){ 
+//               bbSetOutputFileName( std::string( dlg.getInfoImage().mb_str() ) );
+                 if(getImagesSelected().size() ==1)
+                 {
+                       result = getImagesSelected()[0] ;  
+                 } else {
+                               // FCY: it will be a big problem if we have several kind of data in the same folder.
+                               // creation of a huge vtkImageData!!!!
+                               vtkImageData* first = getImagesSelected()[0];
+                               int dim[3];
+                               first->GetDimensions(dim);
+                               if (dim[2]==1)
+                               {
+                                       vtkImageData *out;
+                                       out  = vtkImageData::New();
+                                       out->SetScalarType(first->GetScalarType());
+                                       out->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
+                                       int ext[6];
+                                       first->GetWholeExtent(ext); 
+                                       if(ext[5] == 0)
+                                       {
+                                          ext[5] = getImagesSelected().size()-1;
+                                        } else {
+                                               ext[5] = ext[5] * getImagesSelected().size()-1; // to deal with multiframes 
+                                       } // ext
+                                       out->SetExtent(ext);
+                                       double spac[3];
+                                       first->GetDimensions(dim);
+                                       first->GetSpacing(spac);
+                                       if (spac[0]==spac[1])
+                                       {
+                                               spac[2]=spac[0];  
+                               }
+                                       out->SetSpacing(spac);
+                                       out->SetDimensions(dim[0], dim[1], getImagesSelected().size() );
+                                       out->AllocateScalars();
+                                       out->Update();
+                                       unsigned long imsize = dim[0] * dim[1];
+                                       imsize = imsize * dim[2];  // deal with multiframes here
+                                       // differents formats char , short, etc...
+                                       // differents components 1..3  ex. jpg ->RGB 3
+                                       imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
+                               int slice,sizeImageVector=getImagesSelected().size();
+                                       for (slice=0 ; slice<sizeImageVector ; slice++)
+                                       {
+                                               vtkImageData *img = getImagesSelected()[slice];
+                                               memcpy(out->GetScalarPointer(0,0,slice), img->GetScalarPointer(0,0,0), imsize);
+                                               //img->Delete();
+                                       } // for slice  
+
+//EED This is NOT working. The iteration over the pointer vtkImageData
+//                             int slice=0;
+//                             std::vector<vtkImageData*>::iterator it;
+//                             for (it=dlg.getImagesSelected().begin(); it!=dlg.getImagesSelected().end(); ++it) 
+//                                     {
+//                                               memcpy(out->GetScalarPointer(0,0,slice), (*it)->GetScalarPointer(0,0,0), imsize);
+//                                               slice++;
+//                                     }       
+//                             //for (it=dlg.getImagesSelected().begin(); it!=dlg.getImagesSelected().end(); ++it) 
+//                                     //{
+//                                     //              (*it)->Delete();
+//                                     //}
+
+                                       result =out;
+
+                               } else {
+                                       result = first;
+                               } // dim
+                       } // if getImagesSelected size
+               } else { 
+               result = NULL;  
+               } // getImagesSelected().size()!=0
+
+
+               return result;
+
+               }
+
+
 
-}
+} // namespace creaImageIO
 
index 5e3f5f00f4220c2000f5e7c6757a74b1df39443d..f5723731a23b89bccb14f92e30a4aeefc8e4e389 100644 (file)
@@ -58,6 +58,8 @@ namespace creaImageIO
 
                   /// return a vtkImageData vector of selected images, if available
                   std::vector<vtkImageData*> getImagesSelected();
+                  vtkImageData* getVolumeSelected();
+
                   wxString getInfoImage();
 
                   std::vector< std::map<std::string,std::string> >  getDicomInfoImagesSelected();