Biomedical Image Analysis Library
The Biomedical Image Analysis Library is a poweful tool for developers, physicians, researchers, engineers, and so on.
dragdrop.cpp
Go to the documentation of this file.
1 #include <AdjacencyRound.hpp>
2 #include <BrainInhomogeneity.hpp>
5 #include <ColorMedianFeature.hpp>
6 #include <ConnPathFunction.hpp>
7 #include <DiffusionFunction.hpp>
8 #include <DrawBox.hpp>
9 #include <Feature.hpp>
10 #include <FileImage.hpp>
12 #include <FilteringGaussian.hpp>
13 #include <FilteringMean.hpp>
14 #include <FilteringMedian.hpp>
16 #include <FuzzyCMeans.hpp>
17 #include <GradientCanny.hpp>
18 #include <GradientGabor.hpp>
21 #include <GradientScaleCanny.hpp>
22 #include <GradientSobel.hpp>
23 #include <HeartCOG.hpp>
24 #include <HeartSegmentation.hpp>
25 #include <Image.hpp>
26 #include <ImageIFT.hpp>
27 #include <ImageMerge.hpp>
28 #include <ImageSplit.hpp>
29 #include <MRIModality.hpp>
30 #include <MedianFeature.hpp>
31 #include <MedianFeature.hpp>
32 #include <MorphologyDilation.hpp>
33 #include <MorphologyErosion.hpp>
34 #include <NiftiHeader.hpp>
35 #include <PathFunction.hpp>
36 #include <QDebug>
37 #include <QDesktopWidget>
38 #include <QFileDialog>
39 #include <QInputDialog>
40 #include <QMessageBox>
41 #include <QProgressDialog>
42 #include <QTimer>
43 #include <SegmentationBorder.hpp>
44 #include <SegmentationMST.hpp>
46 #include <SpatialFeature.hpp>
47 #include <Table.hpp>
48 #include <TransformEuclDist.hpp>
49 
50 #include "dragdrop.h"
51 #include "guiimage.h"
52 #include "label.h"
53 #include "ui_dragdrop.h"
54 
55 using namespace std;
56 using namespace Bial;
57 
58 DragDrop::DragDrop( QWidget *parent ) : QWidget( parent ), ui( new Ui::DragDrop ) {
59  ui->setupUi( this );
60 
61  ui->graphicsViewBefore->setScene( new QGraphicsScene( this ) );
62  ui->graphicsViewAfter->setScene( new QGraphicsScene( this ) );
63  ui->graphicsViewInput->setScene( new QGraphicsScene( this ) );
64  ui->graphicsViewOutput->setScene( new QGraphicsScene( this ) );
65 
66  ui->graphicsViewBefore->setFit( true );
67  ui->graphicsViewAfter->setFit( true );
68 
69  model = new QFileSystemModel( this );
70  model->setRootPath( "" );
71  ui->treeView->setModel( model );
72  ui->treeView->setAnimated( false );
73  ui->treeView->setIndentation( 20 );
74  ui->treeView->setSortingEnabled( true );
75  const QSize availableSize = QApplication::desktop( )->availableGeometry( ui->treeView ).size( );
76  ui->treeView->resize( availableSize / 2 );
77  ui->treeView->setColumnWidth( 0, ui->treeView->width( ) / 3 );
78  ui->treeView->setWindowTitle( "Pastas" );
79  ui->treeView->sortByColumn( 0, Qt::AscendingOrder );
80 
81  /*
82  * ui->scrollAreaLeft->hide();
83  * ui->scrollAreaRight->hide();
84  */
85 
86  /*
87  * QList<int> list;
88  * list << 40 << 400;
89  * ui->splitter->setSizes(list);
90  */
91 
92  connect( ui->pushButtonBW, &PushButton::item, this, &DragDrop::processBW );
93  connect( ui->pushButtonInvert, &PushButton::item, this, &DragDrop::processInvert );
94 
95  connect( ui->pushButtonBatchBW, &PushButton::file, this, &DragDrop::processBatchBW );
96 
97  connect( ui->pushButtonInputFolder, &PushButton::file, this, &DragDrop::setInputFolder );
98  connect( ui->pushButtonOutputFolder, &PushButton::file, this, &DragDrop::setOutputFolder );
99 
100  connect( ui->graphicsViewOutput, &GraphicsView::saveFile, this, &DragDrop::saveImage );
101 
102  /* connect(ui->scrollAreaRight, &ScrollArea::item, this, &DragDrop::saveImage); */
103 
104  ui->pushButtonBatchBW->hide( );
105  ui->pushButtonBatchInvert->hide( );
106  ui->pushButtonBW->hide( );
107  ui->pushButtonInvert->hide( );
108 }
109 
111  delete ui;
112 }
113 
114 void DragDrop::processBW( const QString &text ) {
115  qDebug( ) << "text: " << text;
116  if( text == "item" ) {
117  on_pushButtonBW_clicked( );
118  }
119  if( text == "item2" ) {
120  showImage( item2->pixmap( ), item2->fileInfo( ) );
121  on_pushButtonBW_clicked( );
122  }
123 }
124 
125 void DragDrop::processInvert( const QString &text ) {
126  qDebug( ) << "text: " << text;
127  if( text == "item" ) {
128  on_pushButtonInvert_clicked( );
129  }
130  if( text == "item2" ) {
131  showImage( item2->pixmap( ), item2->fileInfo( ) );
132  on_pushButtonInvert_clicked( );
133  }
134 }
135 
136 void DragDrop::processBatchBW( const QString &folder ) {
137  QFileInfo info( folder );
138  if( not info.isDir( ) ) {
139  QMessageBox::critical( this, "Erro!", "Não é pasta!" );
140  return;
141  }
142  outputFolder = folder;
143 
144  setOutputFolder( folder );
145 
146  on_pushButtonBatchBW_clicked( );
147 }
148 
149 void DragDrop::setInputFolder( const QString &path ) {
150  inputFolder = path;
151 
152  ui->groupBoxEntrada->setTitle( "Pasta Entrada: " + path );
153 
154  loadInputFolderThumbs( );
155 }
156 
157 void DragDrop::setOutputFolder( const QString &path ) {
158  outputFolder = path;
159 
160  ui->groupBoxSaida->setTitle( "Pasta Saída: " + path );
161 
162  loadOutputFolderThumbs( );
163  /* loadFolderThumbs(path, ui->scrollAreaRightWidgetContents); */
164 }
165 
166 void DragDrop::saveImage( const QString &text ) { /* TODO: convert text to enum? */
167  if( outputFolder.isEmpty( ) ) {
168  QMessageBox::critical( this, "Erro!", "Não tem pasta de saída!" );
169  return;
170  }
171  QString filePath = text == "item" ? item->fileInfo( ).absoluteFilePath( ) : item2->fileInfo( ).absoluteFilePath( );
172 
173  /* TODO: se nome já existir perguntar se sobrescrever ou renomear */
174 
175  Bial::Write( text == "item" ? m_img->getClrImage( ) : m_img2->getClrImage( ), filePath.toStdString( ) );
176 
177  loadOutputFolderThumbs( );
178 }
179 
180 void DragDrop::on_pushButtonBW_clicked( ) {
181  if( not item or item->pixmap( ).isNull( ) ) {
182  return;
183  }
184  QImage temp = item->pixmap( ).toImage( );
185  temp = temp.convertToFormat( QImage::Format_Grayscale8 );
186  QPixmap pix( QPixmap::fromImage( temp ) );
187 
188  showImage2( pix, item->fileInfo( ) );
189 }
190 
191 void DragDrop::showImage( const QPixmap &pix, const QFileInfo &fileInfo ) {
192  if( item ) {
193  ui->graphicsViewBefore->scene( )->removeItem( item );
194  delete item;
195  }
196  if( m_img ) {
197  delete m_img;
198  }
199  item = new GraphicsItem( "item", pix, fileInfo );
200 
201  ui->graphicsViewBefore->scene( )->setSceneRect( item->pixmap( ).rect( ) );
202 
203  ui->graphicsViewBefore->scene( )->addItem( item );
204  ui->graphicsViewBefore->fitInView( ui->graphicsViewBefore->sceneRect( ), Qt::KeepAspectRatio );
205 
206  /* ------------------------------------------------------ */
207 
208  /* TODO: verify extension before constructing GuiImage (create a static GuiImage function to verify?) */
209  m_img = new GuiImage( fileInfo.absoluteFilePath( ), this );
210  /*
211  * if (img->getSlice(0).isNull()) return;
212  * qDebug() << "bial size: " << img->getSlice(0).size();
213  * item2 = new GraphicsItem("item2", img->getSlice(0), fileName);
214  * ui->graphicsViewAfter->scene()->setSceneRect(item2->pixmap().rect());
215  * ui->graphicsViewAfter->fitInView(ui->graphicsViewAfter->sceneRect(), Qt::KeepAspectRatio);
216  */
217 }
218 
219 void DragDrop::showImage2( const QPixmap &pix, const QFileInfo &fileInfo ) {
220  if( item2 ) {
221  ui->graphicsViewAfter->scene( )->removeItem( item2 );
222  delete item2;
223  }
224  item2 = new GraphicsItem( "item2", pix, fileInfo );
225 
226  ui->graphicsViewAfter->scene( )->setSceneRect( item2->pixmap( ).rect( ) );
227 
228  ui->graphicsViewAfter->scene( )->addItem( item2 );
229  ui->graphicsViewAfter->fitInView( ui->graphicsViewAfter->sceneRect( ), Qt::KeepAspectRatio );
230 }
231 
232 Image< Color > DragDrop::rotateBial( ) {
233  size_t x_size = m_img->getClrImage( ).size( 0 );
234  size_t y_size = m_img->getClrImage( ).size( 1 );
235  Image< Color > res( y_size, x_size );
236  for( size_t y = 0; y < y_size; ++y ) {
237  for( size_t x = 0; x < x_size; ++x ) {
238  res( y, x_size - 1 - x ) = m_img->getClrImage( )( x, y );
239  }
240  }
241  return( res );
242 }
243 
244 Image< int > DragDrop::AnisotropicBial( ) {
245  Image< int > src = m_img->getIntImage( );
246 
247  size_t iterations = QInputDialog::getInt( this, "Iterations", "How many?", 3 ); /* 30 */
248  float kappa = QInputDialog::getInt( this, "Kappa", "How much?", 10 ); /* 10 */
249  float radius = QInputDialog::getInt( this, "Radius", "How much?", 1.01 ); /* 1.01 */
251 
252  Image< int > res( Filtering::AnisotropicDiffusion( src, diff_func, kappa, iterations, radius ) );
253 
254  return( res );
255 }
256 
257 Image< int > DragDrop::CannyBial( ) {
258  Image< int > img = m_img->getIntImage( );
259  float low_thres = QInputDialog::getDouble( this, "Low threshold", "Low: ", 0.7 );
260  float hig_thres = QInputDialog::getDouble( this, "High threshold", "High: ", 0.9 );
261  float sigma = QInputDialog::getDouble( this, "Sigma", "Sigma: ", 1.0 );
262 
263  Image< int > res( Gradient::Canny( img, low_thres, hig_thres, sigma ) );
264 
265  return( res );
266 }
267 
268 void DragDrop::on_pushButtonInvert_clicked( ) {
269  if( not item or item->pixmap( ).isNull( ) ) {
270  return;
271  }
272  if( item->fileInfo( ).suffix( ) == "dcm" ) {
273  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
274  return;
275  }
276  /*
277  * QImage temp = item->pixmap().toImage();
278  * temp.invertPixels();
279  * QPixmap pix(QPixmap::fromImage(temp));
280  */
281 
282  /* */
283 
284  Image< Color > res = rotateBial( );
285 
286  Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) );
287 
288  delete m_img2;
289  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
290 
291  QPixmap pix( m_img2->getSlice( 0 ) );
292 
293  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
294  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
295  if( pix.isNull( ) ) {
296  qDebug( ) << "NULL!";
297  }
298  /* */
299 
300  showImage2( pix, item->fileInfo( ) );
301 }
302 
303 void DragDrop::loadInputFolderThumbs( ) {
304  ui->graphicsViewInput->scene( )->clear( );
305  int x = 0;
306  int y = 0;
307 
308  QFileInfoList list = QDir( inputFolder ).entryInfoList( QDir::NoDotAndDotDot | QDir::AllEntries );
309 
310  QProgressDialog progress( "Reading files...", "Abort", 0, list.size( ), this );
311  progress.setWindowModality( Qt::WindowModal );
312  for( auto file : list ) {
313 
314  qDebug( ) << "file: " << file.fileName( );
315 /*
316  * if( not GuiImage::isSupported( file.absoluteFilePath( ) ) ) {
317  * continue;
318  * }
319  */
320  GuiImage *img = new GuiImage( file.absoluteFilePath( ), this );
321  if( img->getSlice( 0 ).isNull( ) ) {
322  continue;
323  }
324  QPixmap *pix = new QPixmap( img->getSlice( 0 ) );
325 
326  delete img;
327 
328  /*
329  * QPixmap *pix = new QPixmap(file.absoluteFilePath());
330  * if (pix->isNull()) continue;
331  */
332  QPixmap *pixScaled = new QPixmap( pix->scaled( 120, ui->graphicsViewInput->viewport( )->height( ) - 30,
333  Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation ) );
334 
335  GraphicsItem *item = new GraphicsItem( "item", *pixScaled, file );
336  item->setPix2( *pix );
337  item->setFlags( QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable );
338  item->setPos( x, y );
339 
340  connect( item, &GraphicsItem::Image, this, &DragDrop::showImage );
341 
342  x += pixScaled->width( ) + 20;
343 
344  ui->graphicsViewInput->scene( )->addItem( item );
345 
346  qApp->processEvents( );
347  }
348 }
349 
350 void DragDrop::loadOutputFolderThumbs( ) {
351  ui->graphicsViewOutput->scene( )->clear( );
352  int x = 0;
353  int y = 0;
354 
355  QFileInfoList list = QDir( outputFolder ).entryInfoList( QDir::NoDotAndDotDot | QDir::AllEntries );
356 
357  QProgressDialog progress( "Reading files...", "Abort", 0, list.size( ), this );
358  progress.setWindowModality( Qt::WindowModal );
359  for( auto file : list ) {
360 
361  qDebug( ) << "file: " << file.fileName( );
362 /*
363  * if( not GuiImage::isSupported( file.absoluteFilePath( ) ) ) {
364  * continue;
365  * }
366  */
367  GuiImage *img = new GuiImage( file.absoluteFilePath( ), this );
368  if( img->getSlice( 0 ).isNull( ) ) {
369  continue;
370  }
371  QPixmap *pix = new QPixmap( img->getSlice( 0 ) );
372 
373  delete img;
374 
375  /* QPixmap *pix = new QPixmap(file.absoluteFilePath()); */
376  QPixmap *pixScaled = new QPixmap( pix->scaled( 120, ui->graphicsViewOutput->viewport( )->height( ) - 30,
377  Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation ) );
378 
379  GraphicsItem *item = new GraphicsItem( "item", *pixScaled, file.fileName( ) );
380  item->setPix2( *pix );
381  item->setFlags( QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable );
382  item->setPos( x, y );
383 
384  connect( item, &GraphicsItem::Image, this, &DragDrop::showImage );
385 
386  x += pixScaled->width( ) + 20;
387 
388  ui->graphicsViewOutput->scene( )->addItem( item );
389  }
390 }
391 
392 void DragDrop::loadFolderThumbs( QString folder, QWidget *widget ) {
393  /* TODO: separate into two functions: loadInputFolder/loadOutputFolder */
394  qDebug( ) << "name: " << widget->objectName( );
395  if( widget->layout( ) != nullptr ) {
396  QLayoutItem *item;
397  while( ( item = widget->layout( )->takeAt( 0 ) ) != nullptr ) {
398  delete item->widget( );
399  delete item;
400  }
401  }
402  /* */
403  if( widget->objectName( ) == "scrollAreaLeftWidgetContents" ) {
404  ui->graphicsViewInput->scene( )->clear( );
405  int x = 0;
406  int y = 0;
407  /* */
408 
409  QFileInfoList list = QDir( folder ).entryInfoList( QDir::NoDotAndDotDot | QDir::AllEntries );
410 
411  QProgressDialog progress( "Reading files...", "Abort", 0, list.size( ), this );
412  progress.setWindowModality( Qt::WindowModal );
413  for( auto file : list ) {
414 
415  QPixmap *pix = new QPixmap( file.absoluteFilePath( ) );
416  /* QPixmap *pixScaled = new QPixmap(pix->scaled(120, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation)); */
417  QPixmap *pixScaled = new QPixmap( pix->scaled( 120, ui->graphicsViewInput->viewport( )->height( ) - 30,
418  Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation ) );
419 
420  GraphicsItem *item = new GraphicsItem( "item", *pixScaled, file.fileName( ) );
421  item->setPix2( *pix );
422  item->setFlags( QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable );
423  item->setPos( x, y );
424 
425  connect( item, &GraphicsItem::Image, this, &DragDrop::showImage );
426 
427  x += pixScaled->width( ) + 20;
428 
429  ui->graphicsViewInput->scene( )->addItem( item );
430  }
431  }
432  /* */
433 
434  QFileInfoList list = QDir( folder ).entryInfoList( QDir::NoDotAndDotDot | QDir::AllEntries );
435 
436  QProgressDialog progress( "Reading files...", "Abort", 0, list.size( ), this );
437  progress.setWindowModality( Qt::WindowModal );
438  for( auto file : list ) {
439  if( progress.wasCanceled( ) ) {
440  break;
441  }
442  progress.setValue( progress.value( ) + 1 );
443  if( file.isFile( ) ) {
444  createLabel( file, widget );
445  }
446  }
447  progress.cancel( );
448 
449  widget->layout( )->addItem( new QSpacerItem( 40, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
450 }
451 
452 void DragDrop::on_pushButtonBatchBW_clicked( ) {
453  if( outputFolder.isEmpty( ) ) {
454  QMessageBox::critical( this, "Erro!", "Não há pasta de saída definida!" );
455  return;
456  }
457  auto list = ui->graphicsViewInput->scene( )->items( Qt::AscendingOrder );
458  for( auto object : list ) {
459  GraphicsItem *item = static_cast< GraphicsItem* >( object );
460  if( item ) {
461  showImage( item->getPix2( ), item->fileInfo( ) );
462  on_pushButtonBW_clicked( );
463  saveImage( "item2" );
464 
465  QTimer timer;
466  timer.setSingleShot( true );
467  timer.setInterval( 1000 );
468  timer.start( );
469  while( timer.remainingTime( ) > 0 ) {
470  /* wait */
471  }
472  qApp->processEvents( );
473  }
474  }
475 }
476 
477 void DragDrop::createLabel( const QFileInfo &file, const QWidget *widget ) {
478  Label *label = new Label( file.absoluteFilePath( ) );
479  QPixmap *pixmap = new QPixmap( file.absoluteFilePath( ) );
480  if( pixmap->isNull( ) ) {
481  delete label;
482  delete pixmap;
483  return;
484  }
485  *pixmap = pixmap->scaled( 100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation );
486  label->setPixmap( *pixmap );
487  widget->layout( )->addWidget( label );
488 
489  connect( label, &Label::Image, this, &DragDrop::showImage );
490 }
491 
492 /*
493  * void DragDrop::on_actionAbrir_imagem_triggered() {
494  * QString path = QFileDialog::getOpenFileName(this, "Abrir imagem", QDir::currentPath(), "Imagens (*.jpg) ");
495  */
496 
497 /*
498  * if (path.isNull()) return;
499  * }
500  */
501 
502 void DragDrop::on_pushButtonBatchInvert_clicked( ) {
503  /* auto list = ui->scrollAreaLeftWidgetContents->children(); */
504  /*
505  * for (auto object : list) {
506  * Label *label = qobject_cast<Label *>(object);
507  */
508  /*
509  * if (label) {
510  * QFileInfo info(label->filePath);
511  */
512  /*
513  * showImage(label->filePath, info.fileName());
514  * on_pushButtonInvert_clicked();
515  * }
516  * QTimer timer;
517  * timer.setSingleShot(true);
518  * timer.setInterval(1000);
519  * timer.start();
520  * while (timer.remainingTime() > 0) {
521  * // wait
522  * }
523  * qApp->processEvents();
524  * }
525  * loadFolderThumbs(outputFolder, ui->scrollAreaRightWidgetContents);
526  */
527  if( outputFolder.isEmpty( ) ) {
528  QMessageBox::critical( this, "Erro!", "Não há pasta de saída definida!" );
529  return;
530  }
531  auto list = ui->graphicsViewInput->scene( )->items( Qt::AscendingOrder );
532  for( auto object : list ) {
533  GraphicsItem *item = static_cast< GraphicsItem* >( object );
534  if( item ) {
535  showImage( item->getPix2( ), item->fileInfo( ) );
536  on_pushButtonInvert_clicked( );
537  saveImage( "item2" );
538 
539  QTimer timer;
540  timer.setSingleShot( true );
541  timer.setInterval( 1000 );
542  timer.start( );
543  while( timer.remainingTime( ) > 0 ) {
544  /* wait */
545  }
546  qApp->processEvents( );
547  }
548  }
549 }
550 
551 void DragDrop::on_pushButtonInputFolder_clicked( ) {
552  QString path = QFileDialog::getExistingDirectory( this, "Pasta de entrada", QDir::currentPath( ) );
553  if( path.isNull( ) ) {
554  return;
555  }
556  setInputFolder( path );
557 }
558 
559 void DragDrop::on_pushButtonOutputFolder_clicked( ) {
560  outputFolder = QFileDialog::getExistingDirectory( this, "Pasta de saída", QDir::currentPath( ) );
561  if( outputFolder.isNull( ) ) {
562  return;
563  }
564  setOutputFolder( outputFolder );
565 }
566 
567 void DragDrop::on_treeView_doubleClicked( const QModelIndex &index ) {
568  Q_UNUSED( index )
569  /* QString path = model->filePath(index); */
570 
571  /* if (path.isNull()) return; */
572 
573  /* setInputFolder(path); */
574 
575  /* loadFolderThumbs(path, ui->scrollAreaLeftWidgetContents); */
576 }
577 
578 void DragDrop::on_treeView_clicked( const QModelIndex &index ) {
579  QString path = model->filePath( index );
580  if( path.isNull( ) ) {
581  return;
582  }
583  setInputFolder( path );
584 }
585 
586 /*
587  * -----------------------------------------------------------------------------------------------
588  * -----------------------------------------------------------------------------------------------
589  * -----------------------------------------------------------------------------------------------
590  */
591 
592 Bial::Image< int > DragDrop::brain_cmeansclustering( ) {
593  COMMENT( "Reading input data.", 0 );
594  Image< int > scn = m_img->getIntImage( );
595  QString file = QFileDialog::getOpenFileName( this );
596  Image< int > mask( Read< int >( file.toStdString( ) ) );
597 
598  float m = QInputDialog::getDouble( this, "m", "m: ", 2.0, 0 ); /* 2.0 */
599  float epsilon = QInputDialog::getDouble( this, "epsilon", "epsilon: ", 0.1, 0 ); /* 0.1 */
600  size_t clusters = QInputDialog::getInt( this, "clusters", "clusters: ", 3, 0 ); /* 3 */
601 
602  COMMENT( "Running cmeans.", 0 );
603  Feature< int > feats = MedianFeature< int >( scn, mask, AdjacencyType::HyperSpheric( 1.5, scn.Dims( ) ), 0.34
604  );
605 
606  FuzzyCMeans< int > fcm( feats, clusters, m, epsilon );
607  Matrix< double > membership( fcm.Run( false ) );
608  Image< int > result( mask );
609 
610 
611  COMMENT( "Assigning final label.", 0 );
612  for( size_t elm = 0; elm < membership.size( 1 ); ++elm ) {
613  size_t best_clt = 0;
614  for( size_t clt = 1; clt < clusters; ++clt ) {
615  cout << "clt: " << clt << ", elm: " << elm << "." << endl;
616  if( membership( best_clt, elm ) < membership( clt, elm ) ) {
617  best_clt = clt;
618  }
619  }
620  /* result[ feats.Index( elm ) ] = best_clt + 1; */
621  }
622  COMMENT( "Writing result.", 0 );
623  return( result );
624 }
625 
626 Bial::Image< int > DragDrop::brain_inhomogeneity_corretion( ) {
627  Image< int > scn = m_img->getIntImage( );
628  QString file = QFileDialog::getOpenFileName( this );
629  Image< int > msk( Read< int >( file.toStdString( ) ) );
630 
631  float radius = QInputDialog::getDouble( this, "radius", "radius: ", 15.5, 7, 28 ); /* 15.5 */
632 
633  Image< int > res( Brain::InhomogeneityCorrection( scn, msk, radius ) );
634 
635  return( res );
636 }
637 
638 Bial::Image< int > DragDrop::brain_opfclustering( ) {
639  /*
640  * if ((argc < 5) || (argc == 6) || (argc == 8)) {
641  * cout << "Usage: " << argv[0] << " <input image> <brain mask> <modality> <output image> [<csf_min_scl>, "
642  * "<csf_max_scl>] [<gm_min_scl>, <gm_max_scl>]"
643  * << endl;
644  * cout << "\tmodality: T1, T2, or PD." << endl;
645  * cout << "\tcsf_min_scl, csf_max_cls: Default values = 0.4, 0.5. Suggested values: 0.1 <= csf_min_scl <= "
646  * "csf_max_scl <= 0.9."
647  * << endl;
648  * cout << "\tgm_min_scl, gm_max_scl: Default values = 0.4, 0.5. Suggested values: 0.1 <= gm_min_scl <= gm_max_scl
649  * <= "
650  * "0.9."
651  * << endl;
652  * exit(1);
653  * }
654  */
655  /* Fixed number sequence */
656  Common::Randomize( false );
657 
658  /* Validating parameters. */
659  QString q_modality = QInputDialog::getText( this, "Modality", "Modality: " );
660  string modality_str( q_modality.toStdString( ) );
661  MRIModality modality = MRIModality::T1;
662  if( modality_str.compare( "T2" ) == 0 ) {
663  modality = MRIModality::T2;
664  }
665  else if( modality_str.compare( "PD" ) == 0 ) {
666  modality = MRIModality::PD;
667  }
668  else if( modality_str.compare( "T1" ) != 0 ) {
669  cout << "Error: Modality must be T1, T2, or PD. Given \"" << modality_str << "\"." << endl;
670  exit( 1 );
671  }
672  float csf_min_scl = QInputDialog::getDouble( this, "csf_min_scl", "csf_min_scl: ", 0.2 ); /* 0.2 */
673  float csf_max_scl = QInputDialog::getDouble( this, "csf_max_scl", "csf_max_scl: ", 0.3 ); /*
674  * 0.3
675  * if (argc > 5) {
676  */
677  /*
678  * csf_min_scl = atof(argv[5]);
679  * csf_max_scl = atof(argv[6]);
680  * if (csf_min_scl > csf_max_scl) {
681  * cout << "Error: csf_min_scl can not be greater than csf_max_scl. Given: csf_min_scl = " << csf_min_scl
682  * << ", csf_max_scl = " << csf_max_scl << "." << endl;
683  * exit(1);
684  * }
685  * }
686  */
687  float gm_min_scl = QInputDialog::getDouble( this, "gm_min_scl", "gm_min_scl: ", 0.1 ); /* 0.1 */
688  float gm_max_scl = QInputDialog::getDouble( this, "gm_max_scl", "gm_max_scl: ", 0.2 ); /* 0.2 */
689  /*
690  * if (argc > 7) {
691  * gm_min_scl = atof(argv[7]);
692  * gm_max_scl = atof(argv[8]);
693  * if (gm_min_scl > gm_max_scl) {
694  * cout << "Error: gm_min_scl can not be greater than gm_max_scl. Given: gm_min_scl = " << gm_min_scl
695  * << ", gm_max_scl = " << gm_max_scl << "." << endl;
696  * exit(1);
697  * }
698  * }
699  */
700  /* Reading input data */
701  QString q_scn = QFileDialog::getOpenFileName( this, "scn" );
702  Image< int > scn( Read< int >( q_scn.toStdString( ) ) );
703  QString q_mask = QFileDialog::getOpenFileName( this, "mask" );
704  Image< int > mask( Read< int >( q_mask.toStdString( ) ) );
705 
706  /* Running tissue segmentation */
707 
709  mask,
710  modality,
711  csf_min_scl,
712  csf_max_scl,
713  gm_min_scl,
714  gm_max_scl ) );
715 
716 
717  /* Writing result */
718 
719  return( tissues );
720 }
721 
722 Bial::Image< float > DragDrop::brain_segmentation( ) {
723  /*
724  * if (argc != 3) {
725  * cout << "usage: " << argv[0] << " <input> <output>" << endl;
726  * cout << "input: .............. original image." << endl;
727  * cout << "output: .............. segmented heart binary image." << endl;
728  * return (0);
729  * }
730  */
731  /* Reading data contents */
732  /* Image< float > scn( Read< float >( argv[ 1 ] ) ); */
733  Image< float > scn = m_img->getFltImage( );
734 /* NiftiHeader nii( argv[ 1 ] ); */
735  NiftiHeader nii( item->fileInfo( ).fileName( ).toStdString( ) );
736 
737  /* Getting image orientation */
738  string orientation = nii.Orientation( );
739 
740  /* Executing and writing results. */
741 
742  Image< float > res( Brain::SkullStripping( scn, orientation ) );
743  return( res );
744 
745 /* Write(res, argv[2], argv[1]); */
746 }
747 
748 Bial::Image< int > DragDrop::color_cmeans_clustering( ) {
749  /*
750  * if (argc < 3) {
751  * cout << "Usage: " << argv[0] << " <input color image> <output image> [<m>] [<epsilon>] [<clusters>]" << endl;
752  * cout << "\tm: Exponent of cmeans membership function. Default: 2" << endl;
753  * cout << "\tepsilon: Acceptable threshold of minimization function. Default: 0.1" << endl;
754  * cout << "\tclusters: Number of clusters. Default: 3" << endl;
755  * exit(-1);
756  * }
757  */
758  Image< Color > img = m_img->getClrImage( );
759 
760  Adjacency adj_rel( AdjacencyType::Circular( 1.5 ) );
761  Feature< int > feats = Bial::ColorMedianFeature< int >( img, adj_rel, 0.5 );
762 
763 
764  float m = QInputDialog::getDouble( this, "m", "m:" ); /*
765  * 2.0
766  * if (argc > 3) {
767  * m = atoi(argv[3]);
768  * }
769  */
770  float epsilon = QInputDialog::getDouble( this, "epsilon", "epsilon:" ); /*
771  * 0.1
772  * if (argc > 4) {
773  * epsilon = atof(argv[4]);
774  * }
775  */
776  size_t clusters = QInputDialog::getInt( this, "clusters", "clusters:" ); /*
777  * 3
778  * if (argc > 5) {
779  * clusters = atoi(argv[5]);
780  * }
781  */
782 
783  FuzzyCMeans< int > fcm( feats, clusters, m, epsilon );
784  Matrix< double > membership( fcm.Run( false ) );
785 
786  Image< int > result( img.Dim( ), img.PixelSize( ) );
787  for( size_t elm = 0; elm < membership.size( 1 ); ++elm ) {
788  size_t best_clt = 0;
789  for( size_t clt = 1; clt < clusters; ++clt ) {
790  cout << "clt: " << clt << ", elm: " << elm << "." << endl;
791  if( membership( best_clt, elm ) < membership( clt, elm ) ) {
792  best_clt = clt;
793  }
794  }
795  result[ feats.Index( elm ) ] = best_clt + 1;
796  }
797  return( result );
798  /* Write(result, argv[2], argv[1]); */
799 }
800 
801 Bial::Image< int > DragDrop::filtering_adaptive_anisotropic( ) {
802  /*
803  * if ((argc < 4) || (argc > 6)) {
804  * cout << "Usage: " << argv[0] << " <Input image> <output image> <initial_kappa> [<diffusion function> "
805  * << "[<adjacency radius>] ]" << endl;
806  * cout << "\t\t<conservativeness>: (conserve all edges) 0.0 to 1.0 (remove all noise)." << endl;
807  * cout << "\t\t<diffusion function>: 0: Power(1.0); 1: Power(2.0); 2: Gaussian; 3: Robust(0.5); 4: Robust(1.0)."
808  * << "Default: 4." << endl;
809  * cout << "\t\t<initial_kappa>: Kappa for adaptive filtering. Suggested: 50.0 to 2000.0." << endl;
810  * return (0);
811  * }
812  */
813 
814  /* Reading inputs: */
815  Image< int > src = m_img->getIntImage( );
816  float kappa = QInputDialog::getDouble( this, "kappa", "kappa: ", 0, 0, 1 );
817  /*
818  * if ((kappa < 50.0) || (kappa > 2000.0)) {
819  * cout << "Error: Invalid kappa parameter. Expected: 50.0 to 2000.0. Found: " << kappa << endl;
820  * return (0);
821  * }
822  */
823  float radius = QInputDialog::getDouble( this, "radius", "radius: ", 1.01, 0, 1 ); /*
824  * 1.01
825  * if (argc > 5) {
826  * radius = atof(argv[5]);
827  */
828  /*
829  * if ((radius < 1.0) || (radius > 3.0)) {
830  * cout << "Error: Invalid adjacency radius. Expected: 1.0 to 3.0. Found: " << radius << endl;
831  * return (0);
832  * }
833  * }
834  */
835  DiffusionFunction *diff_func = new RobustDiffusionFunction( 0.5 );
836 
837  QStringList options;
838  options << "RobustDiffusion(0.5)"
839  << "RobustDiffusion(1.0)"
840  << "PowerDiffusion(1.0)"
841  << "PowerDiffusion(2.0)"
842  << "GaussianDiffusion";
843 
844  QString option = QInputDialog::getItem( this, "Function", "Function: ", options );
845  if( option == "RobustDiffusion(0.5)" ) {
846  diff_func = new RobustDiffusionFunction( 0.5 );
847  }
848  if( option == "RobustDiffusion(1.0)" ) {
849  diff_func = new RobustDiffusionFunction( 1.0 );
850  }
851  if( option == "PowerDiffusion(1.0)" ) {
852  diff_func = new PowerDiffusionFunction( 1.0 );
853  }
854  if( option == "PowerDiffusion(2.0)" ) {
855  diff_func = new PowerDiffusionFunction( 2.0 );
856  }
857  if( option == "GaussianDiffusion" ) {
858  diff_func = new GaussianDiffusionFunction;
859  }
860  Image< int > res( Filtering::AdaptiveAnisotropicDiffusion( src, diff_func, kappa, radius ) );
861 
862  return( res );
863 /* Write(res, argv[2]); */
864 }
865 
866 Bial::Image< int > DragDrop::filtering_anisotropic( ) {
867  /*
868  * if ((argc < 3) || (argc > 7)) {
869  * cout << "Usage: " << argv[0] << " <Input image> <output image> [<diffusion function> [<iterations> [<kappa> "
870  * << "[<adjacency radius>]]]] " << endl;
871  * cout << "\t\t<diffusion function>: 0: Power(1.0); 1: Power(2.0); 2: Gaussian; 3: Robust(0.5); 4: Robust(1.0)."
872  * << "Default: 4." << endl;
873  * cout << "\t\t<iterations>: 1 to 1000. Default: 3." << endl;
874  * cout << "\t\t<kappa>: 1.0 to 10000.0. Default: 10.0." << endl;
875  * cout << "\t\t<adjacency radius>: 1.0 to 3.0. Default: 1.01." << endl;
876  * return (0);
877  * }
878  */
879  /* Reading inputs: */
880  Image< int > src = m_img->getIntImage( );
881 
882  size_t iterations = QInputDialog::getInt( this, "iterations", "iterations: ", 3 ); /*
883  * 3
884  * if (argc > 4) {
885  */
886  /*
887  * iterations = static_cast<size_t>(atoi(argv[4]));
888  * if ((iterations < 1) || (iterations > 1000)) {
889  * cout << "Error: Invalid number of iterations. Expected: 1 to 1000. Found: " << iterations << endl;
890  * return (0);
891  * }
892  * }
893  */
894  float kappa = QInputDialog::getDouble( this, "kappa", "kappa: ", 10.0 ); /* 10.0 */
895  /*
896  * if (argc > 5) {
897  * kappa = atof(argv[5]);
898  * if ((kappa < 1.0) || (kappa > 10000.0)) {
899  * cout << "Error: Invalid kappa value. Expected: 1.0 to 10000.0. Found: " << kappa << endl;
900  * return (0);
901  * }
902  * }
903  */
904  float radius = QInputDialog::getDouble( this, "radius", "radius: ", 1.01 ); /* 1.01 */
905  /*
906  * if (argc > 6) {
907  * radius = atof(argv[6]);
908  * if ((radius < 1.0) || (radius > 3.0)) {
909  * cout << "Error: Invalid adjacency radius. Expected: 1.0 to 3.0. Found: " << radius << endl;
910  * return (0);
911  * }
912  * }
913  */
914 
915  DiffusionFunction *diff_func = new RobustDiffusionFunction( 0.5 );
916 
917  QStringList options;
918  options << "RobustDiffusion(0.5)"
919  << "RobustDiffusion(1.0)"
920  << "PowerDiffusion(1.0)"
921  << "PowerDiffusion(2.0)"
922  << "GaussianDiffusion";
923 
924  QString option = QInputDialog::getItem( this, "Function", "Function: ", options );
925  if( option == "RobustDiffusion(0.5)" ) {
926  diff_func = new RobustDiffusionFunction( 0.5 );
927  }
928  if( option == "RobustDiffusion(1.0)" ) {
929  diff_func = new RobustDiffusionFunction( 1.0 );
930  }
931  if( option == "PowerDiffusion(1.0)" ) {
932  diff_func = new PowerDiffusionFunction( 1.0 );
933  }
934  if( option == "PowerDiffusion(2.0)" ) {
935  diff_func = new PowerDiffusionFunction( 2.0 );
936  }
937  if( option == "GaussianDiffusion" ) {
938  diff_func = new GaussianDiffusionFunction;
939  }
940  Image< int > res( Filtering::AnisotropicDiffusion( src, diff_func, kappa, iterations, radius ) );
941 
942  return( res );
943 /* Write(res, argv[2]); */
944 }
945 
946 Bial::Image< int > DragDrop::filtering_gaussian( ) {
947  /*
948  * if ((argc < 3) || (argc > 5)) {
949  * cout << "Usage: " << argv[0] << " <input image> <output image> [<radius> [ <stamdard deviation> ] ]" << endl;
950  * cout << "\t\t<radius>: [1.0, 20.0]. Default: 1.9" << endl;
951  * cout << "\t\t<standard deviation>: (0.0,+oo). Default: 2.0" << endl;
952  * return (0);
953  * }
954  */
955 
956  /* reading parameters */
957  float radius = QInputDialog::getDouble( this, "radius", "radius: ", 1.9, 0, 1 ); /* 1.9 */
958  float std_dev = QInputDialog::getDouble( this, "std_dev", "std_dev: ", 2, 0, 1 ); /* 2.0 */
959  /*
960  * if ((radius < 1.0) || (radius > 20.0)) {
961  * cout << "Error: radius range: [1.0, 20.0]. Given: " << radius << endl;
962  * return (0);
963  * }
964  * if (std_dev <= 0.0) {
965  * cout << "Error: Standard deviation range: (0.0, +oo). Given: " << std_dev << endl;
966  * return (0);
967  * }
968  */
969  Image< int > img = m_img->getIntImage( );
970  Image< int > res( Filtering::Gaussian( img, radius, std_dev ) );
971 
972  return( res );
973 /* Write(res, argv[2], argv[1]); */
974 }
975 
976 Bial::Image< int > DragDrop::filtering_mean( ) {
977  /*
978  * if (argc != 4) {
979  * cout << "Usage: " << argv[0] << " <input image> <filtering radius> <output image>" << endl;
980  * return (0);
981  * }
982  */
983  Image< int > img = m_img->getIntImage( );
984  float radius = QInputDialog::getDouble( this, "radius", "radius:" );
985  Image< int > res( Filtering::Mean( img, radius ) );
986 
987  return( res );
988 /* Write(res, argv[3], argv[1]); */
989 }
990 
991 Bial::Image< int > DragDrop::filtering_median( ) {
992  /*
993  * if (argc != 4) {
994  * cout << "Usage: " << argv[0] << " <input image> <filtering radius> <output image>" << endl;
995  * return (0);
996  * }
997  */
998  Image< int > img = m_img->getIntImage( );
999  float radius = QInputDialog::getDouble( this, "radius", "radius:" );
1000  Image< int > res( Filtering::Median( img, radius ) );
1001 
1002  return( res );
1003 /* Write(res, argv[3], argv[1]); */
1004 }
1005 
1006 Bial::Image< int > DragDrop::filtering_optimum_anisotropic( ) {
1007  /*
1008  * if ((argc < 4) || (argc == 7) || (argc > 8)) {
1009  * cout << "Usage: " << argv[0] << " <Input image> <output image> <conservativeness> [<diffusion function> "
1010  * << "[<adjacency radius> [<edge_region> <flat_region>]]]" << endl;
1011  * cout << "\t\t<conservativeness>: (conserve all edges) 0.0 to 1.0 (remove all noise)." << endl;
1012  * cout << "\t\t<diffusion function>: 0: Power(1.0); 1: Power(2.0); 2: Gaussian; 3: Robust(0.5); 4: Robust(1.0)."
1013  * << "Default: 4." << endl;
1014  * cout << "\t\t<edge_region>: Canny edge detection." << endl;
1015  * cout << "\t\t<flat_region>: Background segmentation." << endl;
1016  * return (0);
1017  * }
1018  */
1019 
1020  /* Reading inputs: */
1021  Image< int > src = m_img->getIntImage( );
1022  float conservativeness = QInputDialog::getDouble( this, "conservativeness", "conservativeness:" );
1023  /*
1024  * if ((conservativeness < 0.0) || (conservativeness > 1.0)) {
1025  * cout << "Error: Invalid conservativeness parameter. Expected: 0.0 to 1.0. Found: " << conservativeness << endl;
1026  * return (0);
1027  * }
1028  */
1029  float radius = QInputDialog::getDouble( this, "radius", "radius:" ); /*
1030  * 1.01
1031  * if (argc > 5) {
1032  * radius = atof(argv[5]);
1033  * if ((radius < 1.0) || (radius > 3.0)) {
1034  */
1035  /*
1036  * cout << "Error: Invalid adjacency radius. Expected: 1.0 to 3.0. Found: " << radius << endl;
1037  * return (0);
1038  * }
1039  * }
1040  * DiffusionFunction *diff_func;
1041  * if (argc < 5) {
1042  * diff_func = new RobustDiffusionFunction(1.0);
1043  * } else {
1044  * int func = atof(argv[4]);
1045  * if (func == 0) {
1046  * diff_func = new PowerDiffusionFunction(1.0);
1047  * } else if (func == 1) {
1048  * diff_func = new PowerDiffusionFunction(2.0);
1049  * } else if (func == 2) {
1050  * diff_func = new GaussianDiffusionFunction;
1051  * } else if (func == 3) {
1052  * diff_func = new RobustDiffusionFunction(0.5);
1053  * } else if (func == 4) {
1054  * diff_func = new RobustDiffusionFunction(1.0);
1055  * } else {
1056  * cout << "Error: Invalid diffusion function option. Expected: 0 to 4. Found: " << func << endl;
1057  * return (0);
1058  * }
1059  * }
1060  */
1061  DiffusionFunction *diff_func = new RobustDiffusionFunction( 0.5 );
1062 
1063  QStringList options;
1064  options << "RobustDiffusion(0.5)"
1065  << "RobustDiffusion(1.0)"
1066  << "PowerDiffusion(1.0)"
1067  << "PowerDiffusion(2.0)"
1068  << "GaussianDiffusion";
1069 
1070  QString option = QInputDialog::getItem( this, "Function", "Function: ", options );
1071  if( option == "RobustDiffusion(0.5)" ) {
1072  diff_func = new RobustDiffusionFunction( 0.5 );
1073  }
1074  if( option == "RobustDiffusion(1.0)" ) {
1075  diff_func = new RobustDiffusionFunction( 1.0 );
1076  }
1077  if( option == "PowerDiffusion(1.0)" ) {
1078  diff_func = new PowerDiffusionFunction( 1.0 );
1079  }
1080  if( option == "PowerDiffusion(2.0)" ) {
1081  diff_func = new PowerDiffusionFunction( 2.0 );
1082  }
1083  if( option == "GaussianDiffusion" ) {
1084  diff_func = new GaussianDiffusionFunction;
1085  }
1086  /*
1087  * if (argc > 6) {
1088  * Image<int> edge_region(Read<int>(argv[6]));
1089  * Image<int> flat_region(Read<int>(argv[7]));
1090  * Image<int> res(
1091  * Filtering::OptimumAnisotropicDiffusion(src, diff_func, radius, conservativeness, edge_region, flat_region));
1092  * Write(res, argv[2]);
1093  * } else {
1094  */
1095 
1096  Image< int > res( Filtering::OptimalAnisotropicDiffusion( src, diff_func, radius, conservativeness ) );
1097  return( res );
1098 
1099 /*
1100  * Write(res, argv[2]);
1101  * }
1102  * if (argc < 5) {
1103  * delete (dynamic_cast<RobustDiffusionFunction *>(diff_func));
1104  * } else {
1105  * int func = atof(argv[4]);
1106  * if (func == 0) {
1107  * delete (dynamic_cast<PowerDiffusionFunction *>(diff_func));
1108  * } else if (func == 1) {
1109  * delete (dynamic_cast<PowerDiffusionFunction *>(diff_func));
1110  * } else if (func == 2) {
1111  * delete (dynamic_cast<GaussianDiffusionFunction *>(diff_func));
1112  * } else if (func == 3) {
1113  * delete (dynamic_cast<RobustDiffusionFunction *>(diff_func));
1114  * } else { / * if( func == 4 ) * /
1115  * delete (dynamic_cast<RobustDiffusionFunction *>(diff_func));
1116  * }
1117  * }
1118  */
1119 }
1120 
1121 Bial::Image< int > DragDrop::gradient_canny( ) {
1122  /*
1123  * if (argc != 6) {
1124  * cout << "Usage: " << argv[0] << " <input image> <output image> <lower threshold> <higher threshold> <sigma>"
1125  * << endl;
1126  * cout << "\t\t<lower threshold>, <higher threshold>: Hysteresis thresholds From 0.0 to 1.0." << endl;
1127  * cout << "\t\t<sigma>: Standard deviation of Gaussian filter. From 0.0 to +oo." << endl;
1128  * return (0);
1129  * }
1130  * try {
1131  */
1132  COMMENT( "Reading parameters.", 0 );
1133  Image< int > img = m_img->getIntImage( );
1134  float low_thres = QInputDialog::getDouble( this, "low_thres", "low_thres: ", 0, 0, 1 );
1135  float hig_thres = QInputDialog::getDouble( this, "high_thres", "high_thres: ", 0, 0, 1 );
1136  float sigma = QInputDialog::getDouble( this, "sigma", "sigma: ", 0, 0, 1 );
1137 
1138  COMMENT( "Running Canny.", 0 );
1139  Image< int > res( Gradient::Canny( img, low_thres, hig_thres, sigma ) );
1140 
1141  COMMENT( "Writing result.", 0 );
1142  /* Write(res, argv[2], argv[1]); */
1143  return( res );
1144 /* } */
1145 }
1146 
1147 Bial::Image< int > DragDrop::gradient_directional_sobel( ) {
1148  /*
1149  * if (argc != 4) {
1150  * cout << "Usage: " << argv[0] << " <input image> <output image> <direction> ]" << endl;
1151  * cout << "\t\t<direction>: Lower than the number of dimensions of the input image." << endl;
1152  * return (0);
1153  * }
1154  */
1155  /* reading parameters */
1156  Image< int > img = m_img->getIntImage( );
1157  size_t direction = QInputDialog::getInt( this, "direction", "direction:" );
1158  /*
1159  * if (direction >= img.Dims()) {
1160  * cout << "Error: Invalid direction. Given: " << direction << ". Image dimensions: " << img.Dims() << endl;
1161  * return (0);
1162  * }
1163  */
1164  Image< int > res( Gradient::DirectionalSobel( img, direction ) );
1165 
1166  /* Write(res, argv[2], argv[1]); */
1167 
1168  return( res );
1169 }
1170 
1171 Bial::Image< int > DragDrop::gradient_gabor( ) {
1172  /*
1173  * if ((argc < 4) || (argc > 5)) {
1174  * cout << "Usage: " << argv[0] << " <input image> <standard deviation> <output magnitude> [<output direction> ]"
1175  * << endl;
1176  * return (0);
1177  * }
1178  */
1179 
1180  /* reading parameters */
1181  Image< int > img = m_img->getIntImage( );
1182  Image< int > mag( img );
1183  Image< int > dir( img );
1184  float sigma = QInputDialog::getDouble( this, "sigma", "sigma:" );
1185 
1186  Gradient::Gabor( img, sigma, &mag, &dir );
1187 
1188  /*
1189  * Write(mag, argv[3], argv[1]);
1190  * if (argc == 5) {
1191  * Write(dir, argv[4], argv[1]);
1192  * }
1193  */
1194 
1195  return( mag );
1196 }
1197 
1198 Bial::Image< int > DragDrop::gradient_hole_closing( ) {
1199  /*
1200  * if (argc != 7) {
1201  * cout << "Usage: " << argv[0]
1202  * << " <input image> <output image> <lower threshold> <higher threshold> <sigma> <scales>" << endl;
1203  * cout << "\t\t<lower threshold>, <higher threshold>: Hysteresis thresholds From 0.0 to 1.0." << endl;
1204  * cout << "\t\t<sigma>: Standard deviation of Gaussian filter. From 0.0 to +oo." << endl;
1205  * return (0);
1206  * }
1207  */
1208  COMMENT( "Reading inputs.", 0 );
1209  Image< int > img = m_img->getIntImage( );
1210  float low_thres = QInputDialog::getDouble( this, "low_thres", "low_thres:" );
1211  float hig_thres = QInputDialog::getDouble( this, "high_thres", "high_thres:" );
1212  float sigma = QInputDialog::getDouble( this, "sigma", "sigma:" );
1213  size_t scales = QInputDialog::getInt( this, "scales", "scales:" );
1214 
1215  Image< int > grad( Gradient::MultiScaleCanny( img, low_thres, hig_thres, sigma, scales ) );
1216  COMMENT( "Setting all canny gradient levels to 1.", 0 );
1217  for( size_t pxl = 0; pxl < grad.size( ); ++pxl ) {
1218  if( grad( pxl ) != 0 ) {
1219  grad( pxl ) = 1;
1220  }
1221  }
1222  Image< int > res( Gradient::CloseHoles( grad ) );
1223 
1224 
1225  return( res );
1226 /* Write( res, argv[ 2 ], argv[ 1 ] ); */
1227 }
1228 
1229 Bial::Image< int > DragDrop::gradient_morphological( ) {
1230  /*
1231  * if (argc != 3) {
1232  * cout << "Usage: " << argv[0] << " <input image> <output image>" << endl;
1233  * exit(1);
1234  * }
1235  */
1236  Image< int > img = m_img->getIntImage( );
1237 
1238 
1239  Adjacency spheric = AdjacencyType::HyperSpheric( 1.0, img.Dims( ) );
1240  Image< int > gradient( Image< int >( Gradient::Morphological( img, spheric ) ) );
1241 
1242 
1243  /* Write( gradient, argv[ 2 ], argv[ 1 ] ); */
1244 
1245  return( gradient );
1246 }
1247 
1248 Bial::Image< int > DragDrop::gradient_multiscalecanny( ) {
1249  /*
1250  * if (argc != 7) {
1251  * cout << "Usage: " << argv[0]
1252  * << " <input image> <output image> <lower threshold> <higher threshold> <sigma> <scales>" << endl;
1253  * cout << "\t\t<lower threshold>, <higher threshold>: Hysteresis thresholds From 0.0 to 1.0." << endl;
1254  * cout << "\t\t<sigma>: Standard deviation of Gaussian filter. From 0.0 to +oo." << endl;
1255  * return (0);
1256  * }
1257  */
1258  /* reading parameters */
1259  Image< int > img = m_img->getIntImage( );
1260  float low_thres = QInputDialog::getDouble( this, "low_thres", "low_thres:" );
1261  float hig_thres = QInputDialog::getDouble( this, "high_thres", "high_thres:" );
1262  float sigma = QInputDialog::getDouble( this, "sigma", "sigma:" );
1263  size_t scales = QInputDialog::getInt( this, "scales", "scales:" );
1264 
1265  Image< int > res( Gradient::MultiScaleCanny( img, low_thres, hig_thres, sigma, scales ) );
1266 
1267  return( res );
1268 
1269  /* Write(res, argv[2], argv[1]); */
1270 }
1271 
1272 Bial::Image< int > DragDrop::gradient_multi_scale_size_canny( ) {
1273  /*
1274  * if (argc != 8) {
1275  * cout << "Usage: " << argv[0]
1276  * << " <input image> <output image> <lower threshold> <higher threshold> <sigma> <scales> <fraction>" <<
1277  * endl;
1278  * cout << "\t\t<lower threshold>, <higher threshold>: Hysteresis thresholds From 0.0 to 1.0." << endl;
1279  * cout << "\t\t<sigma>: Standard deviation of Gaussian filter. From 0.0 to +oo." << endl;
1280  * cout << "\t\t<fraction>: Fraction of the maximum edge size to be ignored. In (0.0, 1.0]." << endl;
1281  * return (0);
1282  * }
1283  */
1284  /* reading parameters */
1285  Image< int > img = m_img->getIntImage( );
1286  float low_thres = QInputDialog::getDouble( this, "low_thres", "low_thres: ", 0, 0, 1 );
1287  float hig_thres = QInputDialog::getDouble( this, "high_thres", "high_thres: ", 0, 0, 1 );
1288  float sigma = QInputDialog::getDouble( this, "sigma", "sigma: ", 0, 0, 1 );
1289  size_t scales = QInputDialog::getDouble( this, "scales", "scales: ", 0, 0, 1 );
1290  float fraction = QInputDialog::getDouble( this, "fraction", "fraction: ", 0, 0, 1 );
1291 
1292  Image< int > res( Gradient::MultiScaleSizeCanny( img, low_thres, hig_thres, sigma, scales, fraction ) );
1293 
1294  return( res );
1295 /* Write(res, argv[2], argv[1]); */
1296 }
1297 
1298 Bial::Image< int > DragDrop::gradient_multi_sub_scale_canny( ) {
1299  /*
1300  * if (argc != 7) {
1301  * cout << "Usage: " << argv[0]
1302  * << " <input image> <output image> <lower threshold> <higher threshold> <sigma> <scales>" << endl;
1303  * cout << "\t\t<lower threshold>, <higher threshold>: Hysteresis thresholds From 0.0 to 1.0." << endl;
1304  * cout << "\t\t<sigma>: Standard deviation of Gaussian filter. From 0.0 to +oo." << endl;
1305  * return (0);
1306  * }
1307  */
1308 
1309  /* reading parameters */
1310  Image< int > img = m_img->getIntImage( );
1311  float low_thres = QInputDialog::getDouble( this, "low_thres", "low_thres: ", 0, 0, 1 );
1312  float hig_thres = QInputDialog::getDouble( this, "high_thres", "high_thres: ", 0, 0, 1 );
1313  float sigma = QInputDialog::getDouble( this, "sigma", "sigma: ", 0, 0 );
1314  size_t scales = QInputDialog::getInt( this, "scales", "scales: " );
1315 
1316  Image< int > res( Gradient::MultiSubScaleCanny( img, low_thres, hig_thres, sigma, scales ) );
1317 
1318  return( res );
1319 /* Write(res, argv[2], argv[1]); */
1320 }
1321 
1322 Bial::Image< int > DragDrop::gradient_scalecanny( ) {
1323  /*
1324  * if (argc != 6) {
1325  * cout << "Usage: " << argv[0] << " <input image> <output image> <window side> <lower threshold> <higher
1326  * threshold>"
1327  * << endl;
1328  * cout << "\t\t<lower threshold>, <higher threshold>: From 0.0 to 1.0." << endl;
1329  * cout << "\t\t<window side>: From 1 to window maximum side." << endl;
1330  * return (0);
1331  * }
1332  */
1333  /* reading parameters */
1334  Image< int > img = m_img->getIntImage( );
1335  size_t window_side = QInputDialog::getInt( this, "window_side", "window_side: ", 1, 1 );
1336  float low_thres = QInputDialog::getDouble( this, "low_thres", "low_thres: ", 0, 0, 1 );
1337  float hig_thres = QInputDialog::getDouble( this, "high_thres", "high_thres: ", 0, 0, 1 );
1338 
1339  Image< int > res( Gradient::ScaleCanny( img, window_side, low_thres, hig_thres ) );
1340 
1341  return( res );
1342 /* Write(res, argv[2], argv[1]); */
1343 }
1344 
1345 Bial::Image< int > DragDrop::gradient_sobel( ) {
1346  /*
1347  * if ((argc < 3) || (argc > 4)) {
1348  * cout << "Usage: " << argv[0] << " <input image> <output magnitude> [<output direction> ]" << endl;
1349  * return (0);
1350  * }
1351  */
1352  /* reading parameters */
1353  Image< int > img = m_img->getIntImage( );
1354 
1355  Image< int > mag( img );
1356  Image< int > dir( img );
1357 
1358 /* Gradient::Sobel( img, &mag, &dir ); */
1359 
1360  return( mag );
1361  /*
1362  * Write(mag, argv[2], argv[1]);
1363  * Write(dir, argv[3], argv[1]);
1364  */
1365 }
1366 
1367 Bial::Image< int > DragDrop::gradient_supressed_sobel( ) {
1368  /*
1369  * if (argc != 3) {
1370  * cout << "Usage: " << argv[0] << " <input image> <output magnitude>" << endl;
1371  * return (0);
1372  * }
1373  */
1374  /* reading parameters */
1375  Image< int > img = m_img->getIntImage( );
1376 
1378 
1379  return( res );
1380 /* Write(res, argv[2], argv[1]); */
1381 }
1382 
1383 Bial::Image< float > DragDrop::heart_cog( ) {
1384  /*
1385  * if (argc != 2) {
1386  * cout << "usage: " << argv[0] << " <input>" << endl;
1387  * cout << "input: .............. original image" << endl;
1388  * return (0);
1389  * }
1390  */
1391  /* Reading data contents */
1392 
1393  Image< float > scn = m_img->getFltImage( );
1394  NiftiHeader nii( item->fileInfo( ).absoluteFilePath( ).toStdString( ) );
1395 
1396 
1397  /* Getting image orientation */
1398  string orientation = nii.Orientation( );
1399 
1400  /* Initializing output files */
1401 
1402  Vector< Box > best_rectangles;
1403  Image< float > similarity( scn );
1404 
1405 
1406  /* Computing COG */
1407  Vector< size_t > COG = Heart::WeightedCOG( scn, orientation, best_rectangles, similarity );
1408 
1409  /* Drawing regions to an image */
1410 
1411  Image< int > regions( scn );
1412  regions.Set( 0 );
1413 
1414  std::cout << "Rectangles: " << std::endl;
1415  for( size_t rtg = 0; rtg < best_rectangles.size( ); ++rtg ) {
1416  std::cout << rtg << ":" << std::endl;
1417  best_rectangles[ rtg ].Print( std::cout );
1418  best_rectangles[ rtg ].Draw( regions );
1419  }
1420 /* Printing COG value */
1421  cout << COG[ 0 ] << " " << COG[ 1 ] << " " << COG[ 2 ] << endl;
1422 
1423  /* Writting output images */
1424  return( similarity );
1425 
1426 /*
1427  * Write(similarity, "dat/similarity.nii.gz", argv[1]);
1428  * Write(regions, "dat/regions.nii.gz", argv[1]);
1429  */
1430 
1431 }
1432 
1433 Bial::Image< float > DragDrop::heart_segmentation( ) {
1434  /* Reading data contents */
1435  Image< float > scn = m_img->getFltImage( );
1436  NiftiHeader nii( item->fileInfo( ).absoluteFilePath( ).toStdString( ) );
1437  /* Getting image orientation */
1438  string orientation = nii.Orientation( );
1439  /* Executing and writing results. */
1440  Image< float > res( Heart::Segmentation( scn, orientation ) );
1441  return( res );
1442  /* Write(res, argv[2], argv[1]); */
1443 }
1444 
1445 Bial::Image< int > DragDrop::image_binary_mask( ) {
1446  Image< int > scn = m_img->getIntImage( );
1447  for( size_t p = 0; p < scn.size( ); ++p ) {
1448  if( scn[ p ] != 0 ) {
1449  scn[ p ] = 1;
1450  }
1451  }
1452  return( scn );
1453 }
1454 
1455 Bial::Image< int > DragDrop::image_color_binary_mask( ) {
1456  Image< Color > scn = m_img->getClrImage( );
1457  Image< int > res( scn.Dim( ), scn.PixelSize( ) );
1458  for( size_t chl = 1; chl < 4; ++chl ) {
1459  for( size_t pxl = 0; pxl < scn.size( ); ++pxl ) {
1460  if( scn[ pxl ][ chl ] != 0 ) {
1461  res[ pxl ] = 1;
1462  }
1463  }
1464  }
1465  return( res );
1466 }
1467 
1468 Bial::Image< int > DragDrop::image_dilate( ) {
1469  Image< int > img = m_img->getIntImage( );
1470  float radius = QInputDialog::getDouble( this, "radius", "radius: " ); /* no default */
1471 
1472  Adjacency adj( AdjacencyType::HyperSpheric( radius, img.Dims( ) ) );
1473  Image< int > res( Morphology::Dilate( img, adj ) );
1474 
1475 
1476  return( res );
1477 }
1478 
1479 Bial::Image< int > DragDrop::image_equalize( ) {
1480  Image< int > img = m_img->getIntImage( );
1481 /* Signal eql = Signal::EqualizedHistogram( img ); */
1482  Image< int > res( img );
1483 /*
1484  * for( size_t val = 0; val < eql.size( ); ++val ) {
1485  * eql[ val ] = round( eql[ val ] );
1486  * }
1487  * for( size_t pxl = 0; pxl < img.size( ); ++pxl ) {
1488  * res[ pxl ] = static_cast< int >( eql[ img[ pxl ] ] );
1489  * }
1490  */
1491  return( res );
1492 }
1493 
1494 Bial::Image< int > DragDrop::image_erode( ) {
1495  Image< int > img = m_img->getIntImage( );
1496  float radius = QInputDialog::getDouble( this, "radius", "radius: " ); /* no default */
1497 
1498  Adjacency adj( AdjacencyType::HyperSpheric( radius, img.Dims( ) ) );
1499  Image< int > res( Morphology::Erode( img, adj ) );
1500 
1501 
1502  return( res );
1503 }
1504 
1505 void DragDrop::image_getslice( ) {
1506  /*
1507  * if (argc != 5) {
1508  * cout << "usage: " << argv[0] << " <input 3D image> <output 2D image> <slice number> <direction>" << endl;
1509  * cout << "\t<direction>: 0, 1, or 2." << endl;
1510  * return (0);
1511  * }
1512  * Image<int> img(Read<int>(argv[1]));
1513  * size_t slice = atoi(argv[3]);
1514  * size_t dir = atoi(argv[4]);
1515  * size_t x_size = img.size(0);
1516  * size_t y_size = img.size(1);
1517  * size_t z_size = img.size(2);
1518  * if (dir == 0) {
1519  * Image<int> res(y_size, z_size);
1520  * for (size_t z = 0; z < z_size; ++z) {
1521  * for (size_t y = 0; y < y_size; ++y) {
1522  * res(y, z) = img(slice, y, z);
1523  * }
1524  * }
1525  * Write(res, argv[2], argv[1]);
1526  * } else if (dir == 1) {
1527  * Image<int> res(x_size, z_size);
1528  * for (size_t z = 0; z < z_size; ++z) {
1529  * for (size_t x = 0; x < x_size; ++x) {
1530  * res(x, z) = img(x, slice, z);
1531  * }
1532  * }
1533  * Write(res, argv[2], argv[1]);
1534  * } else {
1535  * Image<int> res(x_size, y_size);
1536  * for (size_t y = 0; y < y_size; ++y) {
1537  * for (size_t x = 0; x < x_size; ++x) {
1538  * res(x, y) = img(x, y, slice);
1539  * }
1540  * }
1541  * Write(res, argv[2], argv[1]);
1542  * }
1543  */
1544 }
1545 
1546 Bial::Image< int > DragDrop::image_ift_watershed( ) {
1547  Image< int > gradient = m_img->getIntImage( );
1548  Image< int > label( Segmentation::Watershed( gradient ) );
1549 
1550  return( label );
1551 }
1552 
1553 Bial::Image< int > DragDrop::image_merge( ) {
1554  QString folder = QFileDialog::getExistingDirectory( this, "Folder" ); /* dicom folder */
1555 
1556  Vector< Image< int > > slices( ReadDir< int >( folder.toStdString( ) ) );
1557  Image< int > merge( ImageOp::Merge( slices ) );
1558 
1559 
1560  return( merge );
1561 }
1562 
1563 Bial::Image< int > DragDrop::image_minimum_spanning_forest( ) {
1564  Image< int > img = m_img->getIntImage( );
1565  size_t classes = QInputDialog::getInt( this, "classes", "classes: " ); /* no default */
1566  Feature< int > feature( img.size( ), 1 );
1567  for( size_t elm = 0; elm < feature.Elements( ); ++elm ) {
1568  feature( elm, 0 ) = img[ elm ];
1569  }
1570  Image< int > label( Segmentation::MinimumSpanningForest( img, feature, classes ) );
1571 
1572  return( label );
1573 }
1574 
1575 Bial::Image< int > DragDrop::image_multiply( ) {
1576  Image< int > img1 = m_img->getIntImage( );
1577  float scalar = QInputDialog::getDouble( this, "scalar", "scalar: " ); /* no default */
1578 
1579  Image< int > res( img1 * scalar );
1580 
1581  return( res );
1582 }
1583 
1584 Bial::Image< Bial::Color > DragDrop::image_multiply_mask( ) {
1585  /*
1586  * if (argc < 4) {
1587  * cout << "Usage: " << argv[0] << " <input image> <binary mask image> <output image>" << endl;
1588  * exit(-1);
1589  * }
1590  */
1591  Image< Color > img = m_img->getClrImage( );
1592  QString q_mask = QFileDialog::getOpenFileName( this, "mask" );
1593  Image< int > mask( Read< int >( q_mask.toStdString( ) ) );
1594 /*
1595  * if( img.Dims( ) != mask.Dims( ) ) {
1596  * cout << "Error: Input images must have the same dimensions." << endl;
1597  * return( 0 );
1598  * }
1599  */
1600  for( size_t pxl = 0; pxl < img.size( ); ++pxl ) {
1601  if( mask[ pxl ] == 0 ) {
1602  for( size_t ch = 1; ch < 4; ++ch ) {
1603  img[ pxl ][ ch ] = 0;
1604  }
1605  }
1606  }
1607  return( img );
1608 }
1609 
1610 Bial::Image< int > DragDrop::transform_euclidean( ) {
1611  Image< int > scn = m_img->getIntImage( );
1612 
1614  Image< int > res( Transform::EDT( bdr ) );
1615 
1616 
1617  return( res );
1618 }
1619 
1620 void DragDrop::on_pushButtonBW_11_clicked( ) {
1621  if( not item or item->pixmap( ).isNull( ) ) {
1622  return;
1623  }
1624  if( item->fileInfo( ).suffix( ) == "dcm" ) {
1625  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
1626  return;
1627  }
1628  /*
1629  * QImage temp = item->pixmap().toImage();
1630  * temp.invertPixels();
1631  * QPixmap pix(QPixmap::fromImage(temp));
1632  */
1633 
1634  /* */
1635 
1636  Image< int > res = transform_euclidean( );
1637 
1638 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
1639 
1640  delete m_img2;
1641  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
1642 
1643  QPixmap pix( m_img2->getSlice( 0 ) );
1644 
1645  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
1646  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
1647  if( pix.isNull( ) ) {
1648  qDebug( ) << "NULL!";
1649  }
1650  /* */
1651 
1652  showImage2( pix, item->fileInfo( ) );
1653 }
1654 
1655 void DragDrop::on_pushButtonBW_13_clicked( ) {
1656  if( not item or item->pixmap( ).isNull( ) ) {
1657  return;
1658  }
1659  if( item->fileInfo( ).suffix( ) == "dcm" ) {
1660  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
1661  return;
1662  }
1663  /*
1664  * QImage temp = item->pixmap().toImage();
1665  * temp.invertPixels();
1666  * QPixmap pix(QPixmap::fromImage(temp));
1667  */
1668 
1669  /* */
1670 
1671  Image< Color > res = image_multiply_mask( );
1672  /*
1673  * Image<int> res = AnisotropicBial();
1674  * Image<int> res = CannyBial();
1675  */
1676 
1677 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
1678 
1679  delete m_img2;
1680  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
1681 
1682  QPixmap pix( m_img2->getSlice( 0 ) );
1683 
1684  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
1685  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
1686  if( pix.isNull( ) ) {
1687  qDebug( ) << "NULL!";
1688  }
1689  /* */
1690 
1691  showImage2( pix, item->fileInfo( ) );
1692 }
1693 
1694 void DragDrop::on_pushButtonBW_7_clicked( ) {
1695  if( not item or item->pixmap( ).isNull( ) ) {
1696  return;
1697  }
1698  if( item->fileInfo( ).suffix( ) == "dcm" ) {
1699  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
1700  return;
1701  }
1702  /*
1703  * QImage temp = item->pixmap().toImage();
1704  * temp.invertPixels();
1705  * QPixmap pix(QPixmap::fromImage(temp));
1706  */
1707 
1708  /* */
1709 
1710  Image< int > res = image_multiply( );
1711  /*
1712  * Image<int> res = AnisotropicBial();
1713  * Image<int> res = CannyBial();
1714  */
1715 
1716 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
1717 
1718  delete m_img2;
1719  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
1720 
1721  QPixmap pix( m_img2->getSlice( 0 ) );
1722 
1723  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
1724  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
1725  if( pix.isNull( ) ) {
1726  qDebug( ) << "NULL!";
1727  }
1728  /* */
1729 
1730  showImage2( pix, item->fileInfo( ) );
1731 }
1732 
1733 void DragDrop::on_pushButtonBW_10_clicked( ) {
1734  if( not item or item->pixmap( ).isNull( ) ) {
1735  return;
1736  }
1737  if( item->fileInfo( ).suffix( ) == "dcm" ) {
1738  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
1739  return;
1740  }
1741  /*
1742  * QImage temp = item->pixmap().toImage();
1743  * temp.invertPixels();
1744  * QPixmap pix(QPixmap::fromImage(temp));
1745  */
1746 
1747  /* */
1748 
1749  Image< int > res = image_minimum_spanning_forest( );
1750  /*
1751  * Image<int> res = AnisotropicBial();
1752  * Image<int> res = CannyBial();
1753  */
1754 
1755 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
1756 
1757  delete m_img2;
1758  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
1759 
1760  QPixmap pix( m_img2->getSlice( 0 ) );
1761 
1762  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
1763  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
1764  if( pix.isNull( ) ) {
1765  qDebug( ) << "NULL!";
1766  }
1767  /* */
1768 
1769  showImage2( pix, item->fileInfo( ) );
1770 }
1771 
1772 void DragDrop::on_pushButtonBW_9_clicked( ) {
1773  if( not item or item->pixmap( ).isNull( ) ) {
1774  return;
1775  }
1776  if( item->fileInfo( ).suffix( ) == "dcm" ) {
1777  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
1778  return;
1779  }
1780  /*
1781  * QImage temp = item->pixmap().toImage();
1782  * temp.invertPixels();
1783  * QPixmap pix(QPixmap::fromImage(temp));
1784  */
1785 
1786  /* */
1787 
1788  Image< int > res = image_merge( );
1789  /*
1790  * Image<int> res = AnisotropicBial();
1791  * Image<int> res = CannyBial();
1792  */
1793 
1794 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
1795 
1796  delete m_img2;
1797  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
1798 
1799  QPixmap pix( m_img2->getSlice( 0 ) );
1800 
1801  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
1802  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
1803  if( pix.isNull( ) ) {
1804  qDebug( ) << "NULL!";
1805  }
1806  /* */
1807 
1808  showImage2( pix, item->fileInfo( ) );
1809 }
1810 
1811 void DragDrop::on_pushButtonBW_8_clicked( ) {
1812  if( not item or item->pixmap( ).isNull( ) ) {
1813  return;
1814  }
1815  if( item->fileInfo( ).suffix( ) == "dcm" ) {
1816  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
1817  return;
1818  }
1819  /*
1820  * QImage temp = item->pixmap().toImage();
1821  * temp.invertPixels();
1822  * QPixmap pix(QPixmap::fromImage(temp));
1823  */
1824 
1825  /* */
1826 
1827  Image< int > res = image_ift_watershed( );
1828  /*
1829  * Image<int> res = AnisotropicBial();
1830  * Image<int> res = CannyBial();
1831  */
1832 
1833 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
1834 
1835  delete m_img2;
1836  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
1837 
1838  QPixmap pix( m_img2->getSlice( 0 ) );
1839 
1840  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
1841  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
1842  if( pix.isNull( ) ) {
1843  qDebug( ) << "NULL!";
1844  }
1845  /* */
1846 
1847  showImage2( pix, item->fileInfo( ) );
1848 }
1849 
1850 void DragDrop::on_pushButtonBW_5_clicked( ) {
1851  if( not item or item->pixmap( ).isNull( ) ) {
1852  return;
1853  }
1854  if( item->fileInfo( ).suffix( ) == "dcm" ) {
1855  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
1856  return;
1857  }
1858  /*
1859  * QImage temp = item->pixmap().toImage();
1860  * temp.invertPixels();
1861  * QPixmap pix(QPixmap::fromImage(temp));
1862  */
1863 
1864  /* */
1865 
1866  Image< int > res = image_erode( );
1867  /*
1868  * Image<int> res = AnisotropicBial();
1869  * Image<int> res = CannyBial();
1870  */
1871 
1872 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
1873 
1874  delete m_img2;
1875  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
1876 
1877  QPixmap pix( m_img2->getSlice( 0 ) );
1878 
1879  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
1880  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
1881  if( pix.isNull( ) ) {
1882  qDebug( ) << "NULL!";
1883  }
1884  /* */
1885 
1886  showImage2( pix, item->fileInfo( ) );
1887 }
1888 
1889 void DragDrop::on_pushButtonBW_4_clicked( ) {
1890  if( not item or item->pixmap( ).isNull( ) ) {
1891  return;
1892  }
1893  if( item->fileInfo( ).suffix( ) == "dcm" ) {
1894  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
1895  return;
1896  }
1897  /*
1898  * QImage temp = item->pixmap().toImage();
1899  * temp.invertPixels();
1900  * QPixmap pix(QPixmap::fromImage(temp));
1901  */
1902 
1903  /* */
1904 
1905  Image< int > res = image_equalize( );
1906  /*
1907  * Image<int> res = AnisotropicBial();
1908  * Image<int> res = CannyBial();
1909  */
1910 
1911 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
1912 
1913  delete m_img2;
1914  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
1915 
1916  QPixmap pix( m_img2->getSlice( 0 ) );
1917 
1918  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
1919  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
1920  if( pix.isNull( ) ) {
1921  qDebug( ) << "NULL!";
1922  }
1923  /* */
1924 
1925  showImage2( pix, item->fileInfo( ) );
1926 }
1927 
1928 void DragDrop::on_pushButtonBW_3_clicked( ) {
1929  if( not item or item->pixmap( ).isNull( ) ) {
1930  return;
1931  }
1932  if( item->fileInfo( ).suffix( ) == "dcm" ) {
1933  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
1934  return;
1935  }
1936  /*
1937  * QImage temp = item->pixmap().toImage();
1938  * temp.invertPixels();
1939  * QPixmap pix(QPixmap::fromImage(temp));
1940  */
1941 
1942  /* */
1943 
1944  Image< int > res = image_dilate( );
1945  /*
1946  * Image<int> res = AnisotropicBial();
1947  * Image<int> res = CannyBial();
1948  */
1949 
1950 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
1951 
1952  delete m_img2;
1953  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
1954 
1955  QPixmap pix( m_img2->getSlice( 0 ) );
1956 
1957  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
1958  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
1959  if( pix.isNull( ) ) {
1960  qDebug( ) << "NULL!";
1961  }
1962  /* */
1963 
1964  showImage2( pix, item->fileInfo( ) );
1965 }
1966 
1967 void DragDrop::on_pushButtonBW_14_clicked( ) {
1968  if( not item or item->pixmap( ).isNull( ) ) {
1969  return;
1970  }
1971  if( item->fileInfo( ).suffix( ) == "dcm" ) {
1972  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
1973  return;
1974  }
1975  /*
1976  * QImage temp = item->pixmap().toImage();
1977  * temp.invertPixels();
1978  * QPixmap pix(QPixmap::fromImage(temp));
1979  */
1980 
1981  /* */
1982 
1983  Image< int > res = image_color_binary_mask( );
1984  /*
1985  * Image<int> res = AnisotropicBial();
1986  * Image<int> res = CannyBial();
1987  */
1988 
1989 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
1990 
1991  delete m_img2;
1992  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
1993 
1994  QPixmap pix( m_img2->getSlice( 0 ) );
1995 
1996  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
1997  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
1998  if( pix.isNull( ) ) {
1999  qDebug( ) << "NULL!";
2000  }
2001  /* */
2002 
2003  showImage2( pix, item->fileInfo( ) );
2004 }
2005 
2006 void DragDrop::on_pushButtonBW_15_clicked( ) {
2007  if( not item or item->pixmap( ).isNull( ) ) {
2008  return;
2009  }
2010  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2011  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2012  return;
2013  }
2014  /*
2015  * QImage temp = item->pixmap().toImage();
2016  * temp.invertPixels();
2017  * QPixmap pix(QPixmap::fromImage(temp));
2018  */
2019 
2020  /* */
2021 
2022  Image< int > res = image_binary_mask( );
2023  /*
2024  * Image<int> res = AnisotropicBial();
2025  * Image<int> res = CannyBial();
2026  */
2027 
2028 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2029 
2030  delete m_img2;
2031  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2032 
2033  QPixmap pix( m_img2->getSlice( 0 ) );
2034 
2035  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2036  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2037  if( pix.isNull( ) ) {
2038  qDebug( ) << "NULL!";
2039  }
2040  /* */
2041 
2042  showImage2( pix, item->fileInfo( ) );
2043 }
2044 
2045 void DragDrop::on_pushButtonBW_16_clicked( ) {
2046  if( not item or item->pixmap( ).isNull( ) ) {
2047  return;
2048  }
2049  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2050  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2051  return;
2052  }
2053  /*
2054  * QImage temp = item->pixmap().toImage();
2055  * temp.invertPixels();
2056  * QPixmap pix(QPixmap::fromImage(temp));
2057  */
2058 
2059  /* */
2060 
2061  Image< float > res = heart_segmentation( );
2062  /*
2063  * Image<int> res = AnisotropicBial();
2064  * Image<int> res = CannyBial();
2065  */
2066 
2067 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2068 
2069  delete m_img2;
2070  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2071 
2072  QPixmap pix( m_img2->getSlice( 0 ) );
2073 
2074  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2075  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2076  if( pix.isNull( ) ) {
2077  qDebug( ) << "NULL!";
2078  }
2079  /* */
2080 
2081  showImage2( pix, item->fileInfo( ) );
2082 }
2083 
2084 void DragDrop::on_pushButtonBW_17_clicked( ) {
2085  if( not item or item->pixmap( ).isNull( ) ) {
2086  return;
2087  }
2088  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2089  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2090  return;
2091  }
2092  /*
2093  * QImage temp = item->pixmap().toImage();
2094  * temp.invertPixels();
2095  * QPixmap pix(QPixmap::fromImage(temp));
2096  */
2097 
2098  /* */
2099 
2100  Image< float > res = heart_cog( );
2101  /*
2102  * Image<int> res = AnisotropicBial();
2103  * Image<int> res = CannyBial();
2104  */
2105 
2106 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2107 
2108  delete m_img2;
2109  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2110 
2111  QPixmap pix( m_img2->getSlice( 0 ) );
2112 
2113  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2114  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2115  if( pix.isNull( ) ) {
2116  qDebug( ) << "NULL!";
2117  }
2118  /* */
2119 
2120  showImage2( pix, item->fileInfo( ) );
2121 }
2122 
2123 void DragDrop::on_pushButtonBW_18_clicked( ) {
2124  if( not item or item->pixmap( ).isNull( ) ) {
2125  return;
2126  }
2127  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2128  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2129  return;
2130  }
2131  /*
2132  * QImage temp = item->pixmap().toImage();
2133  * temp.invertPixels();
2134  * QPixmap pix(QPixmap::fromImage(temp));
2135  */
2136 
2137  /* */
2138 
2139  Image< int > res = gradient_supressed_sobel( );
2140  /*
2141  * Image<int> res = AnisotropicBial();
2142  * Image<int> res = CannyBial();
2143  */
2144 
2145 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2146 
2147  delete m_img2;
2148  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2149 
2150  QPixmap pix( m_img2->getSlice( 0 ) );
2151 
2152  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2153  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2154  if( pix.isNull( ) ) {
2155  qDebug( ) << "NULL!";
2156  }
2157  /* */
2158 
2159  showImage2( pix, item->fileInfo( ) );
2160 }
2161 
2162 void DragDrop::on_pushButtonBW_19_clicked( ) {
2163  if( not item or item->pixmap( ).isNull( ) ) {
2164  return;
2165  }
2166  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2167  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2168  return;
2169  }
2170  /*
2171  * QImage temp = item->pixmap().toImage();
2172  * temp.invertPixels();
2173  * QPixmap pix(QPixmap::fromImage(temp));
2174  */
2175 
2176  /* */
2177 
2178  Image< int > res = gradient_sobel( );
2179  /*
2180  * Image<int> res = AnisotropicBial();
2181  * Image<int> res = CannyBial();
2182  */
2183 
2184 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2185 
2186  delete m_img2;
2187  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2188 
2189  QPixmap pix( m_img2->getSlice( 0 ) );
2190 
2191  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2192  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2193  if( pix.isNull( ) ) {
2194  qDebug( ) << "NULL!";
2195  }
2196  /* */
2197 
2198  showImage2( pix, item->fileInfo( ) );
2199 }
2200 
2201 void DragDrop::on_pushButtonBW_20_clicked( ) {
2202  if( not item or item->pixmap( ).isNull( ) ) {
2203  return;
2204  }
2205  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2206  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2207  return;
2208  }
2209  /*
2210  * QImage temp = item->pixmap().toImage();
2211  * temp.invertPixels();
2212  * QPixmap pix(QPixmap::fromImage(temp));
2213  */
2214 
2215  /* */
2216 
2217  Image< int > res = gradient_scalecanny( );
2218  /*
2219  * Image<int> res = AnisotropicBial();
2220  * Image<int> res = CannyBial();
2221  */
2222 
2223 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2224 
2225  delete m_img2;
2226  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2227 
2228  QPixmap pix( m_img2->getSlice( 0 ) );
2229 
2230  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2231  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2232  if( pix.isNull( ) ) {
2233  qDebug( ) << "NULL!";
2234  }
2235  /* */
2236 
2237  showImage2( pix, item->fileInfo( ) );
2238 }
2239 
2240 void DragDrop::on_pushButtonBW_21_clicked( ) {
2241  if( not item or item->pixmap( ).isNull( ) ) {
2242  return;
2243  }
2244  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2245  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2246  return;
2247  }
2248  /*
2249  * QImage temp = item->pixmap().toImage();
2250  * temp.invertPixels();
2251  * QPixmap pix(QPixmap::fromImage(temp));
2252  */
2253 
2254  /* */
2255 
2256  Image< int > res = gradient_multiscalecanny( );
2257  /*
2258  * Image<int> res = AnisotropicBial();
2259  * Image<int> res = CannyBial();
2260  */
2261 
2262 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2263 
2264  delete m_img2;
2265  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2266 
2267  QPixmap pix( m_img2->getSlice( 0 ) );
2268 
2269  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2270  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2271  if( pix.isNull( ) ) {
2272  qDebug( ) << "NULL!";
2273  }
2274  /* */
2275 
2276  showImage2( pix, item->fileInfo( ) );
2277 }
2278 
2279 void DragDrop::on_pushButtonBW_22_clicked( ) {
2280  if( not item or item->pixmap( ).isNull( ) ) {
2281  return;
2282  }
2283  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2284  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2285  return;
2286  }
2287  /*
2288  * QImage temp = item->pixmap().toImage();
2289  * temp.invertPixels();
2290  * QPixmap pix(QPixmap::fromImage(temp));
2291  */
2292 
2293  /* */
2294 
2295  Image< int > res = gradient_multi_scale_size_canny( );
2296  /*
2297  * Image<int> res = AnisotropicBial();
2298  * Image<int> res = CannyBial();
2299  */
2300 
2301 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2302 
2303  delete m_img2;
2304  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2305 
2306  QPixmap pix( m_img2->getSlice( 0 ) );
2307 
2308  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2309  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2310  if( pix.isNull( ) ) {
2311  qDebug( ) << "NULL!";
2312  }
2313  /* */
2314 
2315  showImage2( pix, item->fileInfo( ) );
2316 }
2317 
2318 void DragDrop::on_pushButtonBW_23_clicked( ) {
2319  if( not item or item->pixmap( ).isNull( ) ) {
2320  return;
2321  }
2322  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2323  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2324  return;
2325  }
2326  /*
2327  * QImage temp = item->pixmap().toImage();
2328  * temp.invertPixels();
2329  * QPixmap pix(QPixmap::fromImage(temp));
2330  */
2331 
2332  /* */
2333 
2334  Image< int > res = gradient_multiscalecanny( );
2335  /*
2336  * Image<int> res = AnisotropicBial();
2337  * Image<int> res = CannyBial();
2338  */
2339 
2340 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2341 
2342  delete m_img2;
2343  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2344 
2345  QPixmap pix( m_img2->getSlice( 0 ) );
2346 
2347  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2348  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2349  if( pix.isNull( ) ) {
2350  qDebug( ) << "NULL!";
2351  }
2352  /* */
2353 
2354  showImage2( pix, item->fileInfo( ) );
2355 }
2356 
2357 void DragDrop::on_pushButtonBW_24_clicked( ) {
2358  if( not item or item->pixmap( ).isNull( ) ) {
2359  return;
2360  }
2361  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2362  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2363  return;
2364  }
2365  /*
2366  * QImage temp = item->pixmap().toImage();
2367  * temp.invertPixels();
2368  * QPixmap pix(QPixmap::fromImage(temp));
2369  */
2370 
2371  /* */
2372 
2373  Image< int > res = gradient_morphological( );
2374  /*
2375  * Image<int> res = AnisotropicBial();
2376  * Image<int> res = CannyBial();
2377  */
2378 
2379 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2380 
2381  delete m_img2;
2382  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2383 
2384  QPixmap pix( m_img2->getSlice( 0 ) );
2385 
2386  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2387  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2388  if( pix.isNull( ) ) {
2389  qDebug( ) << "NULL!";
2390  }
2391  /* */
2392 
2393  showImage2( pix, item->fileInfo( ) );
2394 }
2395 
2396 void DragDrop::on_pushButtonBW_25_clicked( ) {
2397  if( not item or item->pixmap( ).isNull( ) ) {
2398  return;
2399  }
2400  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2401  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2402  return;
2403  }
2404  /*
2405  * QImage temp = item->pixmap().toImage();
2406  * temp.invertPixels();
2407  * QPixmap pix(QPixmap::fromImage(temp));
2408  */
2409 
2410  /* */
2411 
2412  Image< int > res = gradient_hole_closing( );
2413  /*
2414  * Image<int> res = AnisotropicBial();
2415  * Image<int> res = CannyBial();
2416  */
2417 
2418 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2419 
2420  delete m_img2;
2421  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2422 
2423  QPixmap pix( m_img2->getSlice( 0 ) );
2424 
2425  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2426  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2427  if( pix.isNull( ) ) {
2428  qDebug( ) << "NULL!";
2429  }
2430  /* */
2431 
2432  showImage2( pix, item->fileInfo( ) );
2433 }
2434 
2435 void DragDrop::on_pushButtonBW_26_clicked( ) {
2436  if( not item or item->pixmap( ).isNull( ) ) {
2437  return;
2438  }
2439  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2440  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2441  return;
2442  }
2443  /*
2444  * QImage temp = item->pixmap().toImage();
2445  * temp.invertPixels();
2446  * QPixmap pix(QPixmap::fromImage(temp));
2447  */
2448 
2449  /* */
2450 
2451  Image< int > res = gradient_gabor( );
2452  /*
2453  * Image<int> res = AnisotropicBial();
2454  * Image<int> res = CannyBial();
2455  */
2456 
2457 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2458 
2459  delete m_img2;
2460  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2461 
2462  QPixmap pix( m_img2->getSlice( 0 ) );
2463 
2464  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2465  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2466  if( pix.isNull( ) ) {
2467  qDebug( ) << "NULL!";
2468  }
2469  /* */
2470 
2471  showImage2( pix, item->fileInfo( ) );
2472 }
2473 
2474 void DragDrop::on_pushButtonBW_27_clicked( ) {
2475  if( not item or item->pixmap( ).isNull( ) ) {
2476  return;
2477  }
2478  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2479  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2480  return;
2481  }
2482  /*
2483  * QImage temp = item->pixmap().toImage();
2484  * temp.invertPixels();
2485  * QPixmap pix(QPixmap::fromImage(temp));
2486  */
2487 
2488  /* */
2489 
2490  Image< int > res = gradient_directional_sobel( );
2491  /*
2492  * Image<int> res = AnisotropicBial();
2493  * Image<int> res = CannyBial();
2494  */
2495 
2496 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2497 
2498  delete m_img2;
2499  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2500 
2501  QPixmap pix( m_img2->getSlice( 0 ) );
2502 
2503  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2504  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2505  if( pix.isNull( ) ) {
2506  qDebug( ) << "NULL!";
2507  }
2508  /* */
2509 
2510  showImage2( pix, item->fileInfo( ) );
2511 }
2512 
2513 void DragDrop::on_pushButtonBW_28_clicked( ) {
2514  if( not item or item->pixmap( ).isNull( ) ) {
2515  return;
2516  }
2517  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2518  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2519  return;
2520  }
2521  /*
2522  * QImage temp = item->pixmap().toImage();
2523  * temp.invertPixels();
2524  * QPixmap pix(QPixmap::fromImage(temp));
2525  */
2526 
2527  /* */
2528 
2529  Image< int > res = gradient_canny( );
2530  /*
2531  * Image<int> res = AnisotropicBial();
2532  * Image<int> res = CannyBial();
2533  */
2534 
2535 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2536 
2537  delete m_img2;
2538  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2539 
2540  QPixmap pix( m_img2->getSlice( 0 ) );
2541 
2542  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2543  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2544  if( pix.isNull( ) ) {
2545  qDebug( ) << "NULL!";
2546  }
2547  /* */
2548 
2549  showImage2( pix, item->fileInfo( ) );
2550 }
2551 
2552 void DragDrop::on_pushButtonBW_29_clicked( ) {
2553  if( not item or item->pixmap( ).isNull( ) ) {
2554  return;
2555  }
2556  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2557  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2558  return;
2559  }
2560  /*
2561  * QImage temp = item->pixmap().toImage();
2562  * temp.invertPixels();
2563  * QPixmap pix(QPixmap::fromImage(temp));
2564  */
2565 
2566  /* */
2567 
2568  Image< int > res = filtering_optimum_anisotropic( );
2569  /*
2570  * Image<int> res = AnisotropicBial();
2571  * Image<int> res = CannyBial();
2572  */
2573 
2574 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2575 
2576  delete m_img2;
2577  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2578 
2579  QPixmap pix( m_img2->getSlice( 0 ) );
2580 
2581  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2582  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2583  if( pix.isNull( ) ) {
2584  qDebug( ) << "NULL!";
2585  }
2586  /* */
2587 
2588  showImage2( pix, item->fileInfo( ) );
2589 }
2590 
2591 void DragDrop::on_pushButtonBW_30_clicked( ) {
2592  if( not item or item->pixmap( ).isNull( ) ) {
2593  return;
2594  }
2595  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2596  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2597  return;
2598  }
2599  /*
2600  * QImage temp = item->pixmap().toImage();
2601  * temp.invertPixels();
2602  * QPixmap pix(QPixmap::fromImage(temp));
2603  */
2604 
2605  /* */
2606 
2607  Image< int > res = filtering_median( );
2608  /*
2609  * Image<int> res = AnisotropicBial();
2610  * Image<int> res = CannyBial();
2611  */
2612 
2613 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2614 
2615  delete m_img2;
2616  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2617 
2618  QPixmap pix( m_img2->getSlice( 0 ) );
2619 
2620  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2621  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2622  if( pix.isNull( ) ) {
2623  qDebug( ) << "NULL!";
2624  }
2625  /* */
2626 
2627  showImage2( pix, item->fileInfo( ) );
2628 }
2629 
2630 void DragDrop::on_pushButtonBW_31_clicked( ) {
2631  if( not item or item->pixmap( ).isNull( ) ) {
2632  return;
2633  }
2634  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2635  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2636  return;
2637  }
2638  /*
2639  * QImage temp = item->pixmap().toImage();
2640  * temp.invertPixels();
2641  * QPixmap pix(QPixmap::fromImage(temp));
2642  */
2643 
2644  /* */
2645 
2646  Image< int > res = filtering_mean( );
2647  /*
2648  * Image<int> res = AnisotropicBial();
2649  * Image<int> res = CannyBial();
2650  */
2651 
2652 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2653 
2654  delete m_img2;
2655  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2656 
2657  QPixmap pix( m_img2->getSlice( 0 ) );
2658 
2659  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2660  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2661  if( pix.isNull( ) ) {
2662  qDebug( ) << "NULL!";
2663  }
2664  /* */
2665 
2666  showImage2( pix, item->fileInfo( ) );
2667 }
2668 
2669 void DragDrop::on_pushButtonBW_32_clicked( ) {
2670  if( not item or item->pixmap( ).isNull( ) ) {
2671  return;
2672  }
2673  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2674  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2675  return;
2676  }
2677  /*
2678  * QImage temp = item->pixmap().toImage();
2679  * temp.invertPixels();
2680  * QPixmap pix(QPixmap::fromImage(temp));
2681  */
2682 
2683  /* */
2684 
2685  Image< int > res = filtering_gaussian( );
2686  /*
2687  * Image<int> res = AnisotropicBial();
2688  * Image<int> res = CannyBial();
2689  */
2690 
2691 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2692 
2693  delete m_img2;
2694  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2695 
2696  QPixmap pix( m_img2->getSlice( 0 ) );
2697 
2698  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2699  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2700  if( pix.isNull( ) ) {
2701  qDebug( ) << "NULL!";
2702  }
2703  /* */
2704 
2705  showImage2( pix, item->fileInfo( ) );
2706 }
2707 
2708 void DragDrop::on_pushButtonBW_33_clicked( ) {
2709  if( not item or item->pixmap( ).isNull( ) ) {
2710  return;
2711  }
2712  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2713  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2714  return;
2715  }
2716  /*
2717  * QImage temp = item->pixmap().toImage();
2718  * temp.invertPixels();
2719  * QPixmap pix(QPixmap::fromImage(temp));
2720  */
2721 
2722  /* */
2723 
2724  Image< int > res = filtering_anisotropic( );
2725  /*
2726  * Image<int> res = AnisotropicBial();
2727  * Image<int> res = CannyBial();
2728  */
2729 
2730 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2731 
2732  delete m_img2;
2733  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2734 
2735  QPixmap pix( m_img2->getSlice( 0 ) );
2736 
2737  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2738  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2739  if( pix.isNull( ) ) {
2740  qDebug( ) << "NULL!";
2741  }
2742  /* */
2743 
2744  showImage2( pix, item->fileInfo( ) );
2745 }
2746 
2747 void DragDrop::on_pushButtonBW_34_clicked( ) {
2748  if( not item or item->pixmap( ).isNull( ) ) {
2749  return;
2750  }
2751  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2752  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2753  return;
2754  }
2755  /*
2756  * QImage temp = item->pixmap().toImage();
2757  * temp.invertPixels();
2758  * QPixmap pix(QPixmap::fromImage(temp));
2759  */
2760 
2761  /* */
2762 
2763  Image< int > res = filtering_adaptive_anisotropic( );
2764  /*
2765  * Image<int> res = AnisotropicBial();
2766  * Image<int> res = CannyBial();
2767  */
2768 
2769 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2770 
2771  delete m_img2;
2772  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2773 
2774  QPixmap pix( m_img2->getSlice( 0 ) );
2775 
2776  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2777  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2778  if( pix.isNull( ) ) {
2779  qDebug( ) << "NULL!";
2780  }
2781  /* */
2782 
2783  showImage2( pix, item->fileInfo( ) );
2784 }
2785 
2786 void DragDrop::on_pushButtonBW_35_clicked( ) {
2787  if( not item or item->pixmap( ).isNull( ) ) {
2788  return;
2789  }
2790  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2791  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2792  return;
2793  }
2794  /*
2795  * QImage temp = item->pixmap().toImage();
2796  * temp.invertPixels();
2797  * QPixmap pix(QPixmap::fromImage(temp));
2798  */
2799 
2800  /* */
2801 
2802  Image< int > res = color_cmeans_clustering( );
2803  /*
2804  * Image<int> res = AnisotropicBial();
2805  * Image<int> res = CannyBial();
2806  */
2807 
2808 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2809 
2810  delete m_img2;
2811  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2812 
2813  QPixmap pix( m_img2->getSlice( 0 ) );
2814 
2815  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2816  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2817  if( pix.isNull( ) ) {
2818  qDebug( ) << "NULL!";
2819  }
2820  /* */
2821 
2822  showImage2( pix, item->fileInfo( ) );
2823 }
2824 
2825 void DragDrop::on_pushButtonBW_37_clicked( ) {
2826  if( not item or item->pixmap( ).isNull( ) ) {
2827  return;
2828  }
2829  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2830  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2831  return;
2832  }
2833  /*
2834  * QImage temp = item->pixmap().toImage();
2835  * temp.invertPixels();
2836  * QPixmap pix(QPixmap::fromImage(temp));
2837  */
2838 
2839  /* */
2840 
2841  Image< float > res = brain_segmentation( );
2842  /*
2843  * Image<int> res = AnisotropicBial();
2844  * Image<int> res = CannyBial();
2845  */
2846 
2847 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2848 
2849  delete m_img2;
2850  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2851 
2852  QPixmap pix( m_img2->getSlice( 0 ) );
2853 
2854  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2855  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2856  if( pix.isNull( ) ) {
2857  qDebug( ) << "NULL!";
2858  }
2859  /* */
2860 
2861  showImage2( pix, item->fileInfo( ) );
2862 }
2863 
2864 void DragDrop::on_pushButtonBW_38_clicked( ) {
2865  if( not item or item->pixmap( ).isNull( ) ) {
2866  return;
2867  }
2868  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2869  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2870  return;
2871  }
2872  /*
2873  * QImage temp = item->pixmap().toImage();
2874  * temp.invertPixels();
2875  * QPixmap pix(QPixmap::fromImage(temp));
2876  */
2877 
2878  /* */
2879 
2880  Image< int > res = brain_opfclustering( );
2881  /*
2882  * Image<int> res = AnisotropicBial();
2883  * Image<int> res = CannyBial();
2884  */
2885 
2886 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2887 
2888  delete m_img2;
2889  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2890 
2891  QPixmap pix( m_img2->getSlice( 0 ) );
2892 
2893  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2894  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2895  if( pix.isNull( ) ) {
2896  qDebug( ) << "NULL!";
2897  }
2898  /* */
2899 
2900  showImage2( pix, item->fileInfo( ) );
2901 }
2902 
2903 void DragDrop::on_pushButtonBW_39_clicked( ) {
2904  if( not item or item->pixmap( ).isNull( ) ) {
2905  return;
2906  }
2907  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2908  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2909  return;
2910  }
2911  /*
2912  * QImage temp = item->pixmap().toImage();
2913  * temp.invertPixels();
2914  * QPixmap pix(QPixmap::fromImage(temp));
2915  */
2916 
2917  /* */
2918 
2919  Image< int > res = brain_inhomogeneity_corretion( );
2920  /*
2921  * Image<int> res = AnisotropicBial();
2922  * Image<int> res = CannyBial();
2923  */
2924 
2925 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2926 
2927  delete m_img2;
2928  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2929 
2930  QPixmap pix( m_img2->getSlice( 0 ) );
2931 
2932  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2933  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2934  if( pix.isNull( ) ) {
2935  qDebug( ) << "NULL!";
2936  }
2937  /* */
2938 
2939  showImage2( pix, item->fileInfo( ) );
2940 }
2941 
2942 void DragDrop::on_pushButtonBW_40_clicked( ) {
2943  if( not item or item->pixmap( ).isNull( ) ) {
2944  return;
2945  }
2946  if( item->fileInfo( ).suffix( ) == "dcm" ) {
2947  QMessageBox::critical( this, "Erro!", "Suporte a escrita de DICOM ainda não implementado!" );
2948  return;
2949  }
2950  /*
2951  * QImage temp = item->pixmap().toImage();
2952  * temp.invertPixels();
2953  * QPixmap pix(QPixmap::fromImage(temp));
2954  */
2955 
2956  /* */
2957 
2958  Image< int > res = brain_cmeansclustering( );
2959  /*
2960  * Image<int> res = AnisotropicBial();
2961  * Image<int> res = CannyBial();
2962  */
2963 
2964 /* Write( res, QString( outputFolder + "/" + item->fileInfo( ).fileName( ) ).toStdString( ) ); */
2965 
2966  delete m_img2;
2967  m_img2 = new GuiImage( outputFolder + "/" + item->fileInfo( ).fileName( ), this );
2968 
2969  QPixmap pix( m_img2->getSlice( 0 ) );
2970 
2971  qDebug( ) << "x: " << m_img2->getSlice( 0 ).width( );
2972  qDebug( ) << "y: " << m_img2->getSlice( 0 ).height( );
2973  if( pix.isNull( ) ) {
2974  qDebug( ) << "NULL!";
2975  }
2976  /* */
2977 
2978  showImage2( pix, item->fileInfo( ) );
2979 }
2980 
2981 void DragDrop::on_groupBoxSaida_toggled( bool checked ) {
2982  ui->graphicsViewOutput->setVisible( checked );
2983  ui->pushButtonOutputFolder->setVisible( checked );
2984 }
Image< int > TissueSegmentation(const Image< D > &img, const Image< D > &msk, D tissue_intensity, float scl_min, float scl_max, bool hierarchical)
Set labeled clusters into low and high intensity tissues. Low intensity tissue pixels have their labe...
const Vector< size_t > & Index() const
Returns a constant reference to the index vector.
Vector< size_t > COG(const Image< D > &img)
Computes the coordenates of the center of gravity of the input image.
Image< D > Morphological(const Image< D > &image)
Computes the gradient image (dilation - erosion) using spherical adjacency relation of one pixel of r...
Image< D > BorderPixels(const Image< D > &img, const Adjacency &adj)
Pixels belong to the border if they have at last one adjacent pixel with distinct intensity...
Image< D > MultiScaleCanny(const Image< D > &img, float lower_threshold, float higher_threshold, float sigma, size_t scales)
Returns multi scale Canny edge detection image. Lower and higher threshold as frequencies from 0...
size_t Dims() const
Returns the number of dimensions of the image.
void saveFile(const QString &item)
static void Write(const Image< D > &img, const std::string &filename)
Write the input image to a file with given name.
Definition: FileImage.hpp:287
Image< D > InhomogeneityCorrection(const Image< D > &img, const Image< D > &msk, float radius=15.5, size_t compression=2, MRIModality modality=MRIModality::T1)
Computes bias surface based on white matter pixels in the image.
Image< D > Mean(const Image< D > &img, float radius)
Returns the mean filtered image with the given radius.
Vector< float > PixelSize() const
Returns a Vector with all pixel dimensions.
Image< int > MinimumSpanningForest(const Image< D > &img, const Feature< D > feature, size_t regions)
Segmentation by minimum spanning forest algorithm.
The GuiImage class is a bridge to the Bial::Image data structure to the QImage data structure...
Definition: guiimage.h:20
Image< D > DirectionalSobel(const Image< D > &img, size_t direction)
Returns the directional Sobel filter over image.
Image< D > Canny(const Image< D > &suppressed_sobel, float lower_threshold, float higher_threshold)
Returns Canny edge detection image. Lower and higher threshold as frequencies from 0...
Diffusion functions to compute annisotropic filtering and other algorithms.
Image< D > NonMaxSobelSuppression(const Image< D > &img)
Returns the sobel magnitude image with non-maximum intensities suppressed.
Image< D > Dilate(const Image< D > &image)
Computes the dilation of input image using spherical adjacency relation of one pixel of radius...
Matrix< double > Run(bool verbose=false)
Computes fuzzy c-means from 3D image pixels, according to the choosen feature vector.
void Gabor(const Image< D > &img, float sigma, Image< D > *magnitude=nullptr, Image< int > *direction=nullptr)
Returns the directional Gabor filter over image.
QPixmap getPix2() const
Image< Color > Merge(Vector< Image< D > > &img_vector)
Static constructor of a color image, from an vector of monochromatic images.
void file(const QString &text)
Image< D > AdaptiveAnisotropicDiffusion(Image< D > img, const DiffusionFunction *diff_func, float init_kappa, float radius=1.0)
Computes and returns a filtered image by anisotropic diffusion.
Image< D > Segmentation(const Image< D > &img, const std::string &orientation)
Returns a binary mask of segmented heart.
void Set(D val)
Sets val to each element of the entire image.
Content: FuzzyCMeans class Description: Implementation of Fuzzy C-Means clustering algorithm for 3D...
Image< D > EDT(const Image< D > &border)
Computes the Euclidean distance transform, starting from border pixels.
Adjacency relation with indexes following gray code sequency. Future add-on&#39;s: none.
Definition: Adjacency.hpp:19
QPixmap getSlice(size_t view)
getSlice calculates and returns a QImage with the current slice of the view.
Definition: guiimage.cpp:175
Content: NiftiHeader class Description: Magnetic Resonance Image class. Future add-on&#39;s: Complete...
Image< D > Median(const Image< D > &img, float radius)
Returns the median filtered image with the given radius.
void Image(const QPixmap &, const QString &)
Image< D > MultiSubScaleCanny(const Image< D > &img, float lower_threshold, float higher_threshold, float sigma, size_t scales)
Returns multi scale Canny edge detection image. Lower and higher threshold as frequencies from 0...
Image< D > CloseHoles(const Image< D > &canny)
Returns Canny gradient with one pixel wide holes closed.
Adjacency HyperSpheric(float radius=1.0, size_t dims=4)
Create and return a hyper-spheric adjacency relation of radius &#39;radius&#39; and with dim dimensions...
MRIModality
MRI modality.
Definition: MRIModality.hpp:17
Vector< size_t > Dim() const
Returns a Vector with image dimensions.
void item(const QString &text)
O & Print(O &os) const
Prints vector containts to output stream os.
Definition: Vector.hpp:2897
Bial::Image< int > & getIntImage() const
get*Image
Definition: guiimage.cpp:358
Image< D > AnisotropicDiffusion(Image< D > img, const DiffusionFunction *diff_func, float kappa, size_t iterations, float radius=1.0)
Computes and returns a filtered image by anisotropic diffusion.
Image< D > Gaussian(const Image< D > &img, float radius=2.0, float std_dev=2.0)
Returns the median filtered image with the given radius.
DragDrop(QWidget *parent=0)
Definition: dragdrop.cpp:58
size_t size() const noexcept
Returns vector size.
Definition: Vector.hpp:1802
Adjacency Circular(float radius=1.0)
Create and return a 2D circular adjacency relation of radius &#39;radius&#39;.
Image< D > SkullStripping(const Image< D > &img, const std::string &orientation)
Segments the brain from the background.
void Write(const Feature< D > &feat, const std::string &filename)
Writes data to file.
Image< D > MultiScaleSizeCanny(const Image< D > &img, float lower_threshold, float higher_threshold, float sigma, size_t scales, float fraction)
Returns multi scale Canny edge detection image. Lower and higher threshold as frequencies from 0...
Vector< size_t > WeightedCOG(const Image< D > &img, const std::string &orientation)
Returns a Vector with COG coordinates, based on intensity weighted values of the image and distance f...
Image< D > Erode(const Image< D > &image)
Computes the erosion of input image using spherical adjacency relation of one pixel of radius...
void setPix2(const QPixmap &value)
size_t size() const
Returns the image size. Same as Size( ), just for compatibility with std containers.
The Image class is used to handle N-Dimensional images, and has support to Read and Write image files...
Definition: Adjacency.hpp:22
Image< D > ScaleCanny(const Image< D > &img, size_t window_scale, float lower_threshold, float higher_threshold)
Returns a scaled Canny edge detection image. Lower and higher threshold as frequencies from 0...
Adjacency relation and forward iteratior related to a matrix.
Definition: Adjacency.hpp:27
QPixmap pixmap() const
Bial::Image< Bial::Color > & getClrImage() const
Definition: guiimage.cpp:366
std::string Orientation(size_t row) const
Returned std::string can be: LR, RL, SI, IS, AP, PA, or Undefined.
D Minimum(const Image< D > &img, const Image< D > &msk)
Returns the minimum intensity in img restricted to msk pixels which intensities are different form ze...
Definition: gzappend.c:170
void Image(const QPixmap &, const QFileInfo &)
QFileInfo fileInfo() const
Magnetic Resonance Image class.
Image< int > Watershed(Image< D > &gradient, float radius=1.1f)
Returns the label image from Watershed segmentation algorithm using local minima as the leaking point...
Bial::Image< float > & getFltImage() const
Definition: guiimage.cpp:362
Feature vector class. It is essentialy a matrix where, the first dimention refers to the feature and ...
Definition: Feature.hpp:28
Definition: label.h:6
Image< D > OptimalAnisotropicDiffusion(Image< D > img, const DiffusionFunction *diff_func, float radius, float conservativeness)
Threads implementation for anisotropic diffusion filter.