#include "clitkProfileImageGenericFilter.h"
// itk include
-#include "itkBinaryThresholdImageFilter.h"
-#include "itkMaskImageFilter.h"
-#include "itkMaskNegatedImageFilter.h"
+#include <itkLineIterator.h>
#include <clitkCommon.h>
// Reading input
typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
-
- // Main filter
typedef typename InputImageType::PixelType PixelType;
+ typedef typename InputImageType::IndexType IndexType;
typedef itk::Image<uchar, InputImageType::ImageDimension> OutputImageType;
+
+ //Iterator
+ IndexType pointBegin, pointEnd;
+
+ for (int i = 0; i < mArgsInfo.point1_given; ++i) {
+ pointBegin[i] = mArgsInfo.point1_arg[i];
+ pointEnd[i] = mArgsInfo.point2_arg[i];
+ }
+
+ itk::LineConstIterator<InputImageType> itProfile(input, pointBegin, pointEnd);
+ itProfile.GoToBegin();
+ while (!itProfile.IsAtEnd())
+ {
+
+ ++itProfile;
+ }
// Filter
- typedef itk::BinaryThresholdImageFilter<InputImageType, OutputImageType> BinaryThresholdImageFilterType;
- typename BinaryThresholdImageFilterType::Pointer thresholdFilter=BinaryThresholdImageFilterType::New();
- thresholdFilter->SetInput(input);
- thresholdFilter->SetInsideValue(mArgsInfo.fg_arg);
+ //typedef itk::BinaryThresholdImageFilter<InputImageType, OutputImageType> BinaryThresholdImageFilterType;
+ //typename BinaryThresholdImageFilterType::Pointer thresholdFilter=BinaryThresholdImageFilterType::New();
+ //thresholdFilter->SetInput(input);
+ /*thresholdFilter->SetInsideValue(mArgsInfo.fg_arg);
if (mArgsInfo.lower_given) thresholdFilter->SetLowerThreshold(static_cast<PixelType>(mArgsInfo.lower_arg));
if (mArgsInfo.upper_given) thresholdFilter->SetUpperThreshold(static_cast<PixelType>(mArgsInfo.upper_arg));
- /* Three modes :
+ Three modes :
- FG -> only use FG value for pixel in the Foreground (or Inside), keep input values for outside
- BG -> only use BG value for pixel in the Background (or Outside), keep input values for inside
- both -> use FG and BG (real binary image)
- */
+
if (mArgsInfo.mode_arg == std::string("both")) {
thresholdFilter->SetOutsideValue(mArgsInfo.bg_arg);
thresholdFilter->Update();
}
// Write/Save results
this->template SetNextOutput<InputImageType>(outputImage);
- }
+ }*/
}
//--------------------------------------------------------------------
</property>
</widget>
</item>
+ <item row="2" column="2">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="Point2">
+ <property name="text">
+ <string>Point2 (mm): </string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="mPosPoint2Label">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
<item row="2" column="1">
<widget class="QPushButton" name="mSelectPoint2Button">
<property name="text">
</property>
</widget>
</item>
- <item row="3" column="1">
- <widget class="QToolButton" name="mCancelPoints">
- <property name="text">
- <string>Cancel</string>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <layout class="QHBoxLayout" name="horizontalLayout">
+ <item row="3" column="2">
+ <layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
- <widget class="QLabel" name="Point1">
+ <widget class="QToolButton" name="mCancelPointsButton">
<property name="text">
- <string>Point1 (mm): </string>
+ <string>Cancel</string>
</property>
</widget>
</item>
<item>
- <widget class="QLabel" name="mPosPoint1Label">
+ <widget class="QPushButton" name="mComputeProfileButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
- <string/>
+ <string>Compute Profile</string>
</property>
</widget>
</item>
</layout>
</item>
- <item row="2" column="2">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item row="1" column="2">
+ <layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <widget class="QLabel" name="Point2">
+ <widget class="QLabel" name="Point1">
<property name="text">
- <string>Point2 (mm): </string>
+ <string>Point1 (mm): </string>
</property>
</widget>
</item>
<item>
- <widget class="QLabel" name="mPosPoint2Label">
+ <widget class="QLabel" name="mPosPoint1Label">
<property name="text">
<string/>
</property>
// Connect signals & slots
connect(mSelectPoint1Button, SIGNAL(clicked()), this, SLOT(selectPoint1()));
connect(mSelectPoint2Button, SIGNAL(clicked()), this, SLOT(selectPoint2()));
- connect(mCancelPoints, SIGNAL(clicked()), this, SLOT(cancelPoints()));
+ connect(mCancelPointsButton, SIGNAL(clicked()), this, SLOT(cancelPoints()));
+ connect(mComputeProfileButton, SIGNAL(clicked()), this, SLOT(computeProfile()));
// Initialize some widget
//mThresholdSlider1->SetText("");
mPoint1 = NULL;
mPoint2 = NULL;
+
+ point1Selected = false;
+ point2Selected = false;
// Main filter
mFilter = clitk::ProfileImageGenericFilter::New();
point1Selected = false;
if(mCurrentSlicerManager) {
if(mCurrentSlicerManager->GetSelectedSlicer() != -1) {
- double x = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[0];
- double y = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[1];
- double z = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[2];
- position += QString::number(x,'f',1) + " ";
- position += QString::number(y,'f',1) + " ";
- position += QString::number(z,'f',1) + " ";
+ double *pos;
+ int *index;
+ pos = new double [mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
+ index = new int [mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
+
+ for (int i=0; i<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions(); ++i) {
+ pos[i] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[i];
+ index[i] = (int) (pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i];
- mPoint1[0] = x;
- mPoint1[1] = y;
- mPoint1[2] = z;
-
+ position += QString::number(pos[i],'f',1) + " ";
+ mPoint1[i] = index[i];
+ }
point1Selected = true;
}
}
point2Selected = false;
if(mCurrentSlicerManager) {
if(mCurrentSlicerManager->GetSelectedSlicer() != -1) {
- double x = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[0];
- double y = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[1];
- double z = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[2];
- position += QString::number(x,'f',1) + " ";
- position += QString::number(y,'f',1) + " ";
- position += QString::number(z,'f',1) + " ";
+ double *pos;
+ int *index;
+ pos = new double [mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
+ index = new int [mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
+
+ for (int i=0; i<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions(); ++i) {
+ pos[i] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[i];
+ index[i] = (int) (pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i];
- mPoint2[0] = x;
- mPoint2[1] = y;
- mPoint2[2] = z;
-
+ position += QString::number(pos[i],'f',1) + " ";
+ mPoint2[i] = index[i];
+ }
point2Selected = true;
}
}
//------------------------------------------------------------------------------
bool vvToolProfile::isPointsSelected()
{
- if (point1Selected && point2Selected) {
- //Lancer le calcule du profil
- }
+ if (point1Selected && point2Selected)
+ mComputeProfileButton->setEnabled(true);
+ else
+ mComputeProfileButton->setEnabled(false);
return (point1Selected && point2Selected);
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+void vvToolProfile::computeProfile()
+{
+ if (!mCurrentSlicerManager) close();
+
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+ GetArgsInfoFromGUI();
+
+ // Main filter
+ clitk::ProfileImageGenericFilter::Pointer filter = clitk::ProfileImageGenericFilter::New();
+ filter->SetInputVVImage(mCurrentImage);
+ filter->SetArgsInfo(mArgsInfo);
+ filter->Update();
+
+ QApplication::restoreOverrideCursor();
+
+}
+//------------------------------------------------------------------------------
+
+
//------------------------------------------------------------------------------
void vvToolProfile::cancelPoints()
{
mPosPoint2Label->setText(position);
point1Selected = false;
point2Selected = false;
+ mComputeProfileButton->setEnabled(false);
isPointsSelected();
}
//------------------------------------------------------------------------------
{
mCurrentSlicerManager = m;
- mPoint1 = new double[3];
- mPoint2 = new double[3];
- //mPoint1 = new double[m->GetImage()->GetNumberOfSpatialDimensions()];
- //mPoint2 = new double[m->GetImage()->GetNumberOfSpatialDimensions()];
+ mPoint1 = new int[mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
+ mPoint2 = new int[mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()];
+
+ mComputeProfileButton->setEnabled(false);
// Specific for this gui
//mThresholdSlider1->SetValue(0);
mBGSlider->SetValue(0);
mFGSlider->SetSingleStep(1);
mBGSlider->SetSingleStep(1);
-*/
+
// VTK objects for interactive display
for(int i=0; i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
mImageContour.push_back(vvImageContour::New());
//connect(mCurrentSlicerManager,SIGNAL(UpdateOrientation(int,int)),this,SLOT(UpdateOrientation(int, int)));
// connect(mCurrentSlicerManager, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int)));
- InteractiveDisplayToggled(mInteractiveDisplayIsEnabled);
+ InteractiveDisplayToggled(mInteractiveDisplayIsEnabled); */
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvToolProfile::Update(int slicer)
{
- if (!mInteractiveDisplayIsEnabled) return;
+ //if (!mInteractiveDisplayIsEnabled) return;
if (!mCurrentSlicerManager) close();
//mImageContour[slicer]->Update(mThresholdSlider1->GetValue());
//if (mRadioButtonLowerThan->isChecked())
DD(good);
*/
cmdline_parser_clitkProfileImage_init(&mArgsInfo); // Initialisation to default
- bool inverseBGandFG = false;
+ //bool inverseBGandFG = false;
- mArgsInfo.lower_given = 1;
+ //mArgsInfo.lower_given = 1;
/*mArgsInfo.lower_arg = mThresholdSlider1->GetValue();
if (mRadioButtonLowerThan->isChecked()) {
mArgsInfo.upper_given = 1;
} else mArgsInfo.mode_arg = (char*)"FG";
*/
mArgsInfo.verbose_flag = false;
+
+ mArgsInfo.point1_arg = mPoint1;
+ mArgsInfo.point2_arg = mPoint2;
+ mArgsInfo.point1_given = mCurrentSlicerManager->GetImage()->GetNumberOfDimensions();
+ mArgsInfo.point2_given = mCurrentSlicerManager->GetImage()->GetNumberOfDimensions();
+
+ // Required (even if not used)
+ mArgsInfo.input_given = 0;
+ mArgsInfo.output_given = 0;
- // // Required (even if not used)
- // mArgsInfo.input_given = 0;
- // mArgsInfo.output_given = 0;
-
- // mArgsInfo.input_arg = new char;
- // mArgsInfo.output_arg = new char;
+ mArgsInfo.input_arg = new char;
+ mArgsInfo.output_arg = new char;
}
//------------------------------------------------------------------------------