Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "cmtkQtImageOperators.h"
00034
00035 #include <math.h>
00036
00037 #include <qinputdialog.h>
00038
00039 #include <Qt/cmtkQtProgress.h>
00040
00041 #include <Base/cmtkTypedArrayFunctionHistogramEqualization.h>
00042 #include <Base/cmtkDataGridFilter.h>
00043 #include <Base/cmtkMathFunctionWrappers.h>
00044
00045 namespace
00046 cmtk
00047 {
00048
00051
00052 QMenu*
00053 QtImageOperators::CreatePopupMenu()
00054 {
00055 QMenu* operatorsMenu = new QMenu;
00056 operatorsMenu->setTitle( "&Operators" );
00057 operatorsMenu->addAction( "&Median Filter...", this, SLOT( slotOperatorMedian() ) );
00058 operatorsMenu->addAction( "&Histogram Equalization...", this, SLOT( slotOperatorHistEq() ) );
00059 operatorsMenu->addAction( "&Sobel Edge Filter", this, SLOT( slotOperatorSobel() ) );
00060 operatorsMenu->addSeparator();
00061
00062 QMenu* algOperatorsMenu = operatorsMenu->addMenu( "&Algebraic" );
00063 algOperatorsMenu->addAction( "&abs()", this, SLOT( slotOperatorAbs() ) );
00064 algOperatorsMenu->addAction( "&log()", this, SLOT( slotOperatorLog() ) );
00065 algOperatorsMenu->addAction( "&exp()", this, SLOT( slotOperatorExp() ) );
00066
00067 return operatorsMenu;
00068 }
00069
00070 void
00071 QtImageOperators::slotOperatorMedian()
00072 {
00073 if ( this->StudyDataValid() )
00074 {
00075 bool ok;
00076 int radius = QInputDialog::getInt( this->Parent, "Median Filter", "Neighborhood radius:", 1, 1, 5, 1, &ok );
00077 if ( ok )
00078 {
00079
00080 if ( this->ProgressInstance )
00081 this->ProgressInstance->SetProgressWidgetMode( QtProgress::PROGRESS_DIALOG );
00082
00083 (*(this->CurrentStudy))->GetVolume()->SetData( DataGridFilter( (*(this->CurrentStudy))->GetVolume() ).GetDataMedianFiltered( radius ) );
00084
00085 emit dataChanged( *(this->CurrentStudy) );
00086 }
00087 else
00088 {
00089
00090 }
00091 }
00092 }
00093
00094 void
00095 QtImageOperators::slotOperatorSobel()
00096 {
00097 if ( this->StudyDataValid() )
00098 {
00099 if ( this->ProgressInstance )
00100 this->ProgressInstance->SetProgressWidgetMode( QtProgress::PROGRESS_BAR );
00101
00102 (*(this->CurrentStudy))->GetVolume()->SetData( DataGridFilter( (*(this->CurrentStudy))->GetVolume() ).GetDataSobelFiltered() );
00103
00104 emit dataChanged( *(this->CurrentStudy) );
00105 }
00106 }
00107
00108 void
00109 QtImageOperators::slotOperatorHistEq()
00110 {
00111 if ( this->StudyDataValid() )
00112 {
00113 if ( this->ProgressInstance )
00114 this->ProgressInstance->SetProgressWidgetMode( QtProgress::PROGRESS_BAR );
00115 bool ok;
00116 int bins = QInputDialog::getInt( this->Parent, "Histogram Equalization", "Number of Histogram Bins:", 256, 2, 256, 1, &ok );
00117 if ( ok )
00118 {
00119
00120 if ( this->ProgressInstance )
00121 this->ProgressInstance->SetProgressWidgetMode( QtProgress::PROGRESS_DIALOG );
00122 (*(this->CurrentStudy))->GetVolume()->GetData()->ApplyFunctionObject( TypedArrayFunctionHistogramEqualization( (*(*(this->CurrentStudy))->GetVolume()->GetData()), bins ) );
00123 emit dataChanged( *(this->CurrentStudy) );
00124 }
00125 else
00126 {
00127
00128 }
00129 }
00130 }
00131
00132 void
00133 QtImageOperators::slotOperatorAbs()
00134 {
00135 if ( this->StudyDataValid() )
00136 {
00137 (*(this->CurrentStudy))->GetVolume()->GetData()->ApplyFunctionDouble( cmtk::Wrappers::Abs );
00138 emit dataChanged( *(this->CurrentStudy) );
00139 }
00140 }
00141
00142 void
00143 QtImageOperators::slotOperatorLog()
00144 {
00145 if ( this->StudyDataValid() )
00146 {
00147 (*(this->CurrentStudy))->GetVolume()->GetData()->ApplyFunctionDouble( cmtk::Wrappers::Log );
00148 emit dataChanged( *(this->CurrentStudy) );
00149 }
00150 }
00151
00152 void
00153 QtImageOperators::slotOperatorExp()
00154 {
00155 if ( this->StudyDataValid() )
00156 {
00157 (*(this->CurrentStudy))->GetVolume()->GetData()->ApplyFunctionDouble( cmtk::Wrappers::Exp );
00158 emit dataChanged( *(this->CurrentStudy) );
00159 }
00160 }
00161
00162 }