]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxProcessingCTWidget.cxx
84565b7304527e1a72965ce5a3b37b2110fe4c85
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxProcessingCTWidget.cxx
1
2 #include "vtkActor.h"
3 #include "vtkCylinderSource.h"
4 #include "vtkPolyDataMapper.h"
5 #include "vtkRenderer.h"
6 #include "vtkRenderWindow.h"
7 #include "vtkRenderWindowInteractor.h"
8 #include "vtkProperty.h"
9 #include "vtkCamera.h"
10 #include "vtkPoints.h"
11 #include "vtkCellArray.h"
12 #include "vtkPolyData.h"
13 #include "vtkPolyDataMapper.h"
14 #include "vtkPolyDataWriter.h"
15 #include "vtkPolyDataReader.h"
16 #include "vtkImageReader.h"
17 #include "vtkImageViewer.h"
18 #include "vtkImageViewer2.h"
19 #include "vtkImageToStructuredPoints.h"
20
21 #include "vtkExtractVOI.h"
22 #include "vtkImageClip.h"
23 #include "vtkImageResample.h"
24 #include "vtkImageCast.h"
25 #include "vtkImageThreshold.h"
26 #include "vtkImageCast.h"
27 #include "vtkImageSeedConnectivity.h"
28 #include "vtkImageData.h"
29 #include "vtkMarchingCubes.h"
30 #include "vtkImageReslice.h"
31 #include "vtkTransform.h"
32 #include "vtkSphereSource.h"
33 #include "vtkDoubleArray.h"
34 #include "vtkPointData.h"
35 #include "vtkCommand.h"
36 #include "vtkCallbackCommand.h"
37 #include "vtkImageResample.h"
38 #include "vtkMath.h"
39 #include "vtkStripper.h"
40 #include "vtkImageWriter.h"
41 #include "vtkBMPWriter.h"
42 #include "vtkImageCast.h"
43 #include "vtkPolyDataWriter.h"
44
45 #include "wxProcessingCTWidget.h"
46
47 #include <wx/splitter.h>
48 #include <wx/renderer.h>
49 //-------------------------------------------------------------------
50 //-------------------------------------------------------------------
51 //-------------------------------------------------------------------
52
53
54
55 BEGIN_EVENT_TABLE( wxProcessingCTWidget, wxPanel )
56         EVT_MENU( 12121, wxProcessingCTWidget::OnRefreshView )
57 END_EVENT_TABLE( );
58
59 //-------------------------------------------------------------------
60
61
62 wxProcessingCTWidget::wxProcessingCTWidget(wxWindow *parent, marInterfaceCT *mar)
63 : wxPanel( parent, -1) 
64 {
65         wxSplitterWindow                *pnlSplitter            = new wxSplitterWindow( this , -1);
66         wxPanel                         *viewPanel              = CreateViewPanel(pnlSplitter);
67         wxPanel                         *controlPanel           = CreateControlPanel(pnlSplitter);
68
69         pnlSplitter     -> SplitVertically( viewPanel, controlPanel ,300);
70         pnlSplitter     -> SetMinimumPaneSize( 300 );
71
72         wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL  );
73         sizer           -> Add( pnlSplitter ,1,wxALL|wxGROW  ,0);
74         this            -> SetSizer(sizer);
75         this->SetAutoLayout(true);
76 //      panel->SetSize(400,400);
77         this->Layout();
78
79 //EEDxx2.4
80 //      FitInside();
81         _mar = mar;
82         _range[0]=0;
83         _range[1]=255;  
84
85 }
86 //-------------------------------------------------------------------
87 wxProcessingCTWidget::~wxProcessingCTWidget(){
88 // MAZV 27 sep 2006
89 //      _thresh->Delete();
90 //      _connect->Delete();
91
92         _connect2->Delete();
93         
94         _thresh2->Delete();
95
96         delete _imageviewer2D_1;
97         delete _imageviewer2D_2;
98         delete _imageviewer2D_3;
99 }
100 //-------------------------------------------------------------------
101 wxPanel* wxProcessingCTWidget::CreateViewPanel(wxWindow *parent)
102 {
103         wxPanel *panel          =       new wxPanel(parent,-1);
104     wxBoxSizer *sizer   =       new wxBoxSizer(wxVERTICAL);
105
106         _imageviewer2D_1 = new wxVtk2DBaseView(panel);
107         _imageviewer2D_2 = new wxVtk2DBaseView(panel);
108         _imageviewer2D_3 = new wxVtk2DBaseView(panel);
109         wxVTKRenderWindowInteractor *iren   = _imageviewer2D_1->GetWxVTKRenderWindowInteractor();
110         wxVTKRenderWindowInteractor *iren_2 = _imageviewer2D_2->GetWxVTKRenderWindowInteractor();
111         wxVTKRenderWindowInteractor *iren_3 = _imageviewer2D_3->GetWxVTKRenderWindowInteractor();
112         sizer->Add(iren , 1, wxGROW, 0);
113         sizer->Add(iren_2, 1, wxGROW, 0);
114         sizer->Add(iren_3, 1, wxGROW, 0);
115
116
117         panel->SetSizer(sizer);
118         panel->SetAutoLayout(true);
119 //      panel->SetSize(400,400);
120         panel->Layout();
121         return panel;
122 }
123 //-------------------------------------------------------------------
124 wxPanel* wxProcessingCTWidget::CreateControlPanel(wxWindow *parent)
125 {
126         _parent=parent;
127         wxPanel *panel          = new wxPanel(parent,-1);
128         _lowthreshold           = new wxSlider( panel, -1,65000 , 64000, 65000, wxDefaultPosition, wxSize(25,25), wxSL_HORIZONTAL | wxSL_LABELS | wxSL_AUTOTICKS  );
129         _lowthreshold->SetTickFreq(50,0);
130
131         _midthreshold           = new wxSlider( panel, -1, 65000 , 64000, 65000, wxDefaultPosition, wxSize(25,25), wxSL_HORIZONTAL | wxSL_LABELS | wxSL_AUTOTICKS );
132         _midthreshold->SetTickFreq(50,0);
133
134
135         _lowthresholdSpin1      = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
136         _lowthresholdSpin1->SetRange(1,8);
137         _lowthresholdSpin1->SetValue(5);
138         Connect(_lowthresholdSpin1->GetId()  , wxEVT_COMMAND_SLIDER_UPDATED      , (wxObjectEventFunction) &wxProcessingCTWidget::OnSpinLowThresholdSpin1 ); 
139 //      Connect(_lowthresholdSpin1->GetId()  , wxEVT_SCROLL_THUMBTRACK   , (wxObjectEventFunction) &wxProcessingCTWidget::OnSpinLowThresholdSpin1 ); 
140
141         _lowthresholdSpin2      = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
142         _lowthresholdSpin2->SetRange(1,8);
143         _lowthresholdSpin2->SetValue(5);
144         Connect(_lowthresholdSpin2->GetId()  , wxEVT_COMMAND_SLIDER_UPDATED      , (wxObjectEventFunction) &wxProcessingCTWidget::OnSpinLowThresholdSpin2 ); 
145 //      Connect(_lowthresholdSpin2->GetId()  , wxEVT_SCROLL_THUMBTRACK   , (wxObjectEventFunction) &wxProcessingCTWidget::OnSpinLowThresholdSpin2 ); 
146
147
148
149 // MAZV 27 sep 2006
150 //      _highthreshold          = new wxSlider( panel, -1, 50, 0, 100 , wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
151         _zslice                         = new wxSlider( panel, -1, 50, 0, 100 , wxDefaultPosition, wxSize(25,25), wxSL_HORIZONTAL | wxSL_LABELS | wxSL_AUTOTICKS );
152         _zslice->SetTickFreq(10,0);
153         _extract                        = new wxButton( panel, -1, _T("Axis extraction"));
154 //      _midthreshold->SetSize(250,20);
155 // MAZV 27 sep 2006
156         //_highthreshold->SetSize(250,20);  // Result Volume
157
158 //          wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
159     wxBoxSizer *sizer   = new wxBoxSizer(wxVERTICAL );
160
161         int flag = wxALL | wxGROW ;
162
163         sizer->Add(new wxStaticText(panel,-1,_T("  "))                                                  , 1, flag, 0);
164         sizer->Add(new wxStaticText(panel,-1,_T("  "))                                                  , 1, flag, 0);
165         sizer->Add(new wxStaticText(panel,-1,_T("Lower vascular threshold"))                            , 1, flag, 0);  
166
167     wxBoxSizer *sizerLowThreshold       = new wxBoxSizer(wxHORIZONTAL );
168         sizerLowThreshold->Add(_lowthresholdSpin1                                                       );
169         sizerLowThreshold->Add(_lowthreshold                                                            , 1, wxALL | wxGROW , 0);
170         sizer->Add(sizerLowThreshold                                                                    , 1, wxALL | wxGROW , 0);
171
172         sizer->Add(new wxStaticText(panel,-1,_T("  "))                                                  , 1, flag, 0);
173         sizer->Add(new wxStaticText(panel,-1,_T("Higher vascular threshold"))                           , 1, flag, 0);
174
175     wxBoxSizer *sizerMidThreshold       = new wxBoxSizer(wxHORIZONTAL );
176         sizerMidThreshold->Add(_lowthresholdSpin2                                                       );
177         sizerMidThreshold->Add(_midthreshold                                                            , 1, flag, 0);
178         sizer->Add(sizerMidThreshold                                                                    , 1, flag, 0);
179         
180
181 // MAZV 27 sep 2006
182 //      sizer->Add(new wxStaticText(panel,-1,"  "));
183 //      sizer->Add(new wxStaticText(panel,-1,"Calcification threshold"));
184 //      sizer->Add(_highthreshold);
185
186
187         sizer->Add(new wxStaticText(panel,-1,_T("  "))                                                  , 1, flag, 0);
188         sizer->Add(new wxStaticText(panel,-1,_T("Z Slice"))                                             , 1, flag, 0);
189         sizer->Add(_zslice                                                                              , 1, flag, 0);
190         sizer->Add(new wxStaticText(panel,-1,_T("  "))                                                  , 1, flag, 0);
191         sizer->Add(_extract                                                                             , 1, flag, 0);
192
193 //      panel->SetSize(200,200);
194         panel->SetSizer(sizer);
195         panel->SetAutoLayout(true);
196         panel->Layout();
197 //      panel->FitInside(parent);
198
199         Connect(_lowthreshold->GetId()  , wxEVT_SCROLL_CHANGED                  , (wxObjectEventFunction) &wxProcessingCTWidget::OnLowThreshold); 
200         Connect(_lowthreshold->GetId()  , wxEVT_SCROLL_THUMBTRACK               , (wxObjectEventFunction) &wxProcessingCTWidget::OnLowThreshold); 
201         Connect(_midthreshold->GetId()  , wxEVT_SCROLL_CHANGED                  , (wxObjectEventFunction) &wxProcessingCTWidget::OnMidThreshold ); 
202         Connect(_midthreshold->GetId()  , wxEVT_SCROLL_THUMBTRACK               , (wxObjectEventFunction) &wxProcessingCTWidget::OnMidThreshold ); 
203
204
205 // MAZV 27 sep 2006
206 //  Connect(_highthreshold->GetId() , wxEVT_SCROLL_THUMBTRACK           , (wxObjectEventFunction) &wxProcessingCTWidget::OnHighThreshold );
207
208         Connect(_zslice->GetId()                , wxEVT_SCROLL_CHANGED                  , (wxObjectEventFunction) &wxProcessingCTWidget::OnZSlice );
209         Connect(_zslice->GetId()                , wxEVT_SCROLL_THUMBTRACK               , (wxObjectEventFunction) &wxProcessingCTWidget::OnZSlice );
210
211         Connect(_extract->GetId()               , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxProcessingCTWidget::OnExtract );
212         return panel;
213 }
214
215
216 //------------------------------------------------------------------------
217
218 void wxProcessingCTWidget::Refresh()
219 {
220         int z = (int)(_vtkbasedata_1->GetZ( ));
221
222         _vtkbasedata_1->SetZ( z );
223         _vtkbasedata_2->SetZ( z );
224         _vtkbasedata_3->SetZ( z );
225
226         _imageviewer2D_3->Refresh();
227         _imageviewer2D_1->Refresh();
228         _imageviewer2D_2->Refresh();
229
230         _imageviewer2D_3->RefreshView();
231         _imageviewer2D_1->RefreshView();
232         _imageviewer2D_2->RefreshView();
233
234
235 }
236
237 //----------------------------------------------------------------------------
238 void wxProcessingCTWidget::OnSpinLowThresholdSpin1(wxScrollEvent& event)
239 {
240         int value = _lowthreshold->GetValue();
241         int delta = (int) (pow( 4 , _lowthresholdSpin1->GetValue() ));
242         int min   = value - delta/2;
243         int max   = value + delta/2;
244         if (min<0)
245         {
246                 min=0;
247                 max=delta;
248         }
249         _lowthreshold->SetRange(min,max);
250 }
251
252 //----------------------------------------------------------------------------
253 void wxProcessingCTWidget::OnSpinLowThresholdSpin2(wxScrollEvent& event)
254 {
255         int value = _midthreshold->GetValue();
256         int delta = (int)(pow( 4 , _lowthresholdSpin2->GetValue() ));
257         int min=value - delta/2;
258         int max=value + delta/2;
259         if (min<0)
260         {
261                 min=0;
262                 max=delta;
263         }
264         _midthreshold->SetRange(min,max);
265 }
266
267
268 //----------------------------------------------------------------------------
269 void wxProcessingCTWidget::OnRefreshView(wxCommandEvent & event)
270 {
271         Refresh();
272 }
273
274 //------------------------------------------------------------------------
275
276 void wxProcessingCTWidget::ConfigureVTK(marImageData *marimagedata, int x, int y, int z)
277 {
278     wxBusyCursor wait;
279
280         _x = x;
281         _y = y;
282         _z = z;
283
284         vtkImageData *imagedata=marimagedata->GetImageData();
285         imagedata->UpdateInformation();
286         imagedata->SetUpdateExtent(imagedata->GetWholeExtent());
287         imagedata->Update();
288
289         data = imagedata;
290
291         double puntoactualprov[3];
292         puntoactualprov[0] = x;
293         puntoactualprov[1] = y;
294         puntoactualprov[2] = z;
295
296         double espprin[3];
297         int extprin[6];                         
298         
299         imagedata->GetSpacing(espprin);
300         imagedata->GetExtent(extprin);
301
302
303 // MAZV 27 sep 2006
304 //      puntoactualprov[0]=puntoactualprov[0]*espprin[0];
305 //      puntoactualprov[1]=puntoactualprov[1]*espprin[1];
306 //      puntoactualprov[2]=puntoactualprov[2]*espprin[2];
307         
308     imagedata->GetScalarRange( _range );
309
310
311         // Update Controls
312         _lowthreshold->SetRange( (int)(_range[0]), (int)(_range[1]));
313         _lowthreshold->SetValue( (int)(_range[1]/4) );
314
315         _midthreshold->SetRange( (int)(_range[0]),  (int)(_range[1]));
316         _midthreshold->SetValue( (int)(_range[1]/2) );
317
318 // MAZV 27 sep 2006
319 //      _highthreshold->SetRange(_range[0], _range[1]);
320 //      _highthreshold->SetValue( _range[1] );
321
322         _zslice->SetRange(extprin[4], extprin[5]);
323         _zslice->SetValue(extprin[5]/2);
324     
325         
326         _thresh = vtkImageThreshold::New();
327         _thresh->SetInput(imagedata);
328         //_thresh->ReleaseDataFlagOff();
329         _thresh->SetInValue(255);
330         _thresh->SetOutputScalarTypeToUnsignedShort();
331         _thresh->SetOutValue(0);
332         _thresh->ThresholdBetween(_lowthreshold->GetValue(), _range[1]);
333
334         vtkImageCast *cast = vtkImageCast::New();
335         cast->SetInput(_thresh->GetOutput());
336         cast->SetOutputScalarTypeToUnsignedChar();
337         cast->Update();
338
339   
340         _connect = vtkImageSeedConnectivity::New();
341         _connect->SetInput(cast->GetOutput());
342         _connect->SetInputConnectValue(255);
343         _connect->SetOutputConnectedValue(255);
344         _connect->SetOutputUnconnectedValue(0);
345         _connect->AddSeed( (int)(puntoactualprov[0]), (int)(puntoactualprov[1]), (int)(puntoactualprov[2]));
346         _connect->Update();
347
348         cast3 = vtkImageCast::New();
349         cast3->SetInput(_connect->GetOutput());
350         cast3->SetOutputScalarTypeToUnsignedShort();
351         cast3->Update();
352
353         _thresh2 = vtkImageThreshold::New();
354         _thresh2->SetInput(imagedata);
355         //_thresh2->ReleaseDataFlagOff();
356         _thresh2->SetInValue(255);
357         _thresh2->SetOutputScalarTypeToUnsignedShort();
358         _thresh2->SetOutValue(0);
359         _thresh2->ThresholdBetween(_lowthreshold->GetValue(), _midthreshold->GetValue());
360
361         vtkImageCast *cast2 = vtkImageCast::New();
362         cast2->SetInput(_thresh2->GetOutput());
363         cast2->SetOutputScalarTypeToUnsignedChar();
364         cast2->Update();
365
366
367         _connect2 = vtkImageSeedConnectivity::New();
368         _connect2->SetInput(cast2->GetOutput());
369         _connect2->SetInputConnectValue(255);
370         _connect2->SetOutputConnectedValue(255);
371         _connect2->SetOutputUnconnectedValue(0);
372         _connect2->AddSeed(  (int)(puntoactualprov[0]),  (int)(puntoactualprov[1]),  (int)(puntoactualprov[2]) );
373         _connect2->Update();
374
375         cast4 = vtkImageCast::New();
376         cast4->SetInput(_connect2->GetOutput());
377         cast4->SetOutputScalarTypeToUnsignedShort();
378         cast4->Update();
379
380         // Interface Update
381
382         _vtkbasedata_1 = new vtkBaseData();
383         _vtkbasedata_1->SetMarImageData(marimagedata);
384         
385
386         cast3->GetOutput()->UpdateInformation();
387         cast3->GetOutput()->SetUpdateExtent( cast3->GetOutput()->GetWholeExtent() );
388         cast3->GetOutput()->SetUpdateExtent( cast3->GetOutput()->GetWholeExtent() );
389         
390         cast3->GetOutput()->Update();
391         _vtkbasedata_2 = new vtkBaseData();
392         _vtkbasedata_2->SetMarImageData( new marImageData(cast3->GetOutput()) );
393
394
395         cast4->GetOutput()->UpdateInformation();
396         cast4->GetOutput()->SetUpdateExtent(cast4->GetOutput()->GetWholeExtent());
397         cast4->GetOutput()->Update();
398         _vtkbasedata_3 = new vtkBaseData();
399         _vtkbasedata_3->SetMarImageData( new marImageData(cast4->GetOutput() ));
400
401         _imageviewer2D_1->SetVtkBaseData( _vtkbasedata_1  );
402         _imageviewer2D_1->Configure();
403
404         _imageviewer2D_2->SetVtkBaseData( _vtkbasedata_2  );
405         _imageviewer2D_2->Configure();
406
407         _imageviewer2D_3->SetVtkBaseData( _vtkbasedata_3  );
408         _imageviewer2D_3->Configure();
409 // EED 31 Mai 2007
410 //      Refresh();
411         
412 }
413
414
415 //------------------------------------------------------------------------
416 void wxProcessingCTWidget::MidThreshold()
417 {
418         _thresh2->ThresholdBetween(_lowthreshold->GetValue(), _midthreshold->GetValue());
419         _thresh2->Update();
420 }
421
422
423 //------------------------------------------------------------------------
424 void wxProcessingCTWidget::LowThreshold()
425 {
426 // MAZV 27 sep 2006
427 //      _thresh->ThresholdBetween(_lowthreshold->GetValue(), _highthreshold->GetValue());
428 //      _thresh->Update();
429
430 // MAZV 3 oct 2006
431         _thresh->ThresholdBetween(_lowthreshold->GetValue(), _range[1] );
432         _thresh->Update();
433         
434         MidThreshold();
435
436 }
437
438 //------------------------------------------------------------------------
439 void wxProcessingCTWidget::OnLowThreshold(wxScrollEvent& event)
440 {       
441         LowThreshold();
442         Refresh();
443 }
444 //------------------------------------------------------------------------
445 void wxProcessingCTWidget::OnMidThreshold(wxScrollEvent& event){
446         MidThreshold();
447         Refresh();
448 }
449
450 //------------------------------------------------------------------------
451 // MAZV 27 sep 2006
452 //void wxProcessingCTWidget::OnHighThreshold(wxScrollEvent& event){
453 //   _thresh->ThresholdBetween(_lowthreshold->GetValue(), _highthreshold->GetValue());
454 //      Refresh();
455 //}
456
457 //------------------------------------------------------------------------
458 void wxProcessingCTWidget::OnZSlice(wxScrollEvent& event){
459         _vtkbasedata_1->SetZ( _zslice->GetValue() );
460 //      _vtkbasedata_2->SetZ( _zslice->GetValue() );
461 //      _vtkbasedata_3->SetZ( _zslice->GetValue() );
462         Refresh();
463 }
464 //------------------------------------------------------------------------
465 void wxProcessingCTWidget::OnExtract(wxCommandEvent& event){
466         
467     wxBusyCursor wait;
468     int ext[6];
469
470     vtkImageChangeInformation* change = vtkImageChangeInformation::New();
471     change->SetInput( _vtkbasedata_3->GetImageData() );
472     
473         _vtkbasedata_3->GetImageData()->GetWholeExtent(ext);
474     change->SetExtentTranslation( -ext[0], -ext[2], -ext[4] );
475     change->Update();
476         
477     vtkImageData *image = change->GetOutput();
478
479     marParameters *marParam  = new marParameters();
480     marParam->copyFrom ( *(_mar->getParameters()) );
481     marParam->setDoubleParam( marParameters::e_RescaleIntercept , 0 );
482     marParam->setDoubleParam( marParameters::e_RescaleSlope     , 1 );
483
484     marExperiment *newExperiment = new marExperiment( marParam );
485
486     kVolume *vol = new kVolume( image  );
487     newExperiment->setVOI(ext);
488     newExperiment->initExperiment(vol);
489     newExperiment->setStartPoint( _x, _y, _z);
490     newExperiment->extractVascularTree();
491
492         //_mar->_experiment->initExperiment(new kVolume(data));
493         _mar->appendAxis(newExperiment->getAxis(0));
494         //_mar->_experiment->setVOI(ext);
495         _mar->setAxis(0);
496         _mar->prepareQuantification( );
497
498         wxCommandEvent ev(wxEVT_COMMAND_MENU_SELECTED,20005);
499         _parent->ProcessEvent( ev );
500
501         int size = _mar->getNumberOfSlices( );
502
503         if (size != 0){
504                 wxString msg;
505                 msg.Printf(_T("Axis Extracted"));
506                 wxMessageDialog(this, msg,_T("Information")).ShowModal();
507         }
508         
509
510 /*
511         FILE *ff;
512     ff=fopen("c:/Temp/DATOS.txt","a+");
513         fprintf(ff,"z:%d -  x:%d y:%d\n",size,ext[1]+1,ext[3]+1,ext[5]+1);
514         fclose(ff);
515
516         vtkImageWriter *w = vtkImageWriter::New();
517
518         
519         for (int i = 0; i < size; i++){
520                 std::string path = "C:/TEMP/";
521                 w->SetInput(_mar->_experiment->getSliceImage(i));
522                 char *f = "";
523                 f = itoa(i, f, 10);
524                 std::string fil(f);
525
526                 path.append(fil.c_str());
527                 w->SetFileName(path.c_str());
528                 w->Write();
529         }
530         w->Delete();
531 */
532
533
534 /*      vtkBMPWriter *w = vtkBMPWriter::New();
535         vtkImageCast *c = vtkImageCast::New();
536
537         for (int i = 0; i < size; i++){
538                 std::string path = "C:/TEMP/";
539                 
540
541                 c->SetInput(_mar->_experiment->getSliceImage(i));
542                 c->SetOutputScalarTypeToUnsignedChar();
543                 c->Update();
544
545                 w->SetInput(c->GetOutput());
546                 char *f = "";
547                 f = itoa(i, f, 10);
548                 std::string fil(f);
549
550                 path.append(fil.c_str());
551                 path.append(".bmp");
552                 w->SetFileName(path.c_str());
553                 w->Write();
554         }*/
555
556         //Escritura a pcx con LibIDO
557 /*
558         for ( int i = 0; i < size; i++){
559                 PPIMAGE_USHORT imalibido = (PPIMAGE_USHORT) IdImaAlloc(128,128, IMA_USHORT);
560                 for (int j = 0; j < 128; j++){
561                         for (int k = 0; k < 128; k++){
562                                 imalibido[k][j] = (unsigned short)_mar->_experiment->getSliceImage(i)->GetScalarComponentAsDouble(j, k, 0, 0);
563                         }
564                 }
565                 std::string path = "C:/TEMP/";
566                 char *f = "";
567                 f = itoa(i, f, 10);
568                 std::string fil(f);
569                 path.append(fil.c_str());
570                 path.append(".pcx");
571                 PPIMAGE_UCHAR imagennueva =  IdImaRecad16To8(imalibido, -1, -1);
572                 IdImaWritePCXFile((char*)path.c_str(), imagennueva);
573                 IdImaClear((PPIMAGE)imalibido);
574         }
575
576 */
577
578 }
579
580
581 //------------------------------------------------------------------------
582 void wxProcessingCTWidget::SetThreshold(int min ,int max)
583 {
584         _lowthreshold->SetValue(min);
585         _midthreshold->SetValue(max);
586         LowThreshold();
587 }
588 //------------------------------------------------------------------------
589 void wxProcessingCTWidget::GetThreshold(int *min        ,int *max)
590 {
591         *min = _lowthreshold->GetValue();
592         *max = _midthreshold->GetValue();
593 }
594
595
596 //------------------------------------------------------------------------
597