Commit 6b11504e authored by saubatn's avatar saubatn
Browse files

FEATURE 193 Partial derivative properties updated.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1613 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 687d10a2
......@@ -64,21 +64,21 @@ AnisotropicDiffusion::AnisotropicDiffusion(ActionExtension * extension) : Action
this->addTag("Perona and Malik");
// Setting parameters default values by using properties
this->addParameter(new Property(tr("Keep original image voxel type"), true,
addParameter(new Property(tr("Keep original image voxel type"), true,
tr("Keep the original image voxel type ?"), ""));
Property* nbIterationProperty = new Property(tr("Number of iterations"), 5,
tr("The more iterations, the more smoothing. \nEach iteration takes the same amount of time. \nIf it takes 10 seconds for one iteration, then it will take 100 seconds for 10 iterations. \nNote that the conductance controls how much each iteration smooths across edges. "), "");
nbIterationProperty->setAttribute("minimum", 1);
nbIterationProperty->setAttribute("maximum", 100);
nbIterationProperty->setAttribute("singleStep", 1);
this->addParameter(nbIterationProperty);
addParameter(nbIterationProperty);
Property* conductanceProperty = new Property(tr("Conductance"), 1.0,
tr("Conductance controls the sensitivity of the conductance term. \nAs a general rule, the lower the value, the more strongly the filter preserves edges. \nA high value will cause diffusion (smoothing) across edges. \nNote that the number of iterations controls how much smoothing is done within regions bounded by edges."), "");
conductanceProperty->setAttribute("minimum", 0.10);
conductanceProperty->setAttribute("maximum", 10.00);
conductanceProperty->setAttribute("singleStep", 0.05);
this->addParameter(conductanceProperty);
addParameter(conductanceProperty);
Property* implementationProperty = new Property("Diffusion type", AnisotropicDiffusion::GRADIENT,
"The type of diffusion to use.", "");
......@@ -86,7 +86,7 @@ AnisotropicDiffusion::AnisotropicDiffusion(ActionExtension * extension) : Action
QStringList possibleValues;
possibleValues << "Gradient" << "Curvature";
implementationProperty->setAttribute("enumNames", possibleValues);
this->addParameter(implementationProperty);
addParameter(implementationProperty);
}
......
......@@ -91,5 +91,5 @@ protected:
double conductance;
};
Q_DECLARE_METATYPE(AnisotropicDiffusion::AnisoDiffType);
Q_DECLARE_METATYPE(AnisotropicDiffusion::AnisoDiffType)
#endif // ANISOTROPICDIFFUSION_H
......@@ -60,21 +60,21 @@ CannyEdgeDetection::CannyEdgeDetection(ActionExtension * extension) : Action(ext
// Setting parameters default values
Property* keepOrgVoxelTypeProperty = new Property(tr("Keep original voxel type?"), true, tr("Does the output image have the same voxel type as the input one?"), "");
this->addParameter(keepOrgVoxelTypeProperty);
addParameter(keepOrgVoxelTypeProperty);
Property* varianceProperty = new Property(tr("Variance"), 2.0, tr("The variance is used in the gaussian preprocessing step. \nThe higher the variance is, the less the edges detection will be noise sensitive."), "");
varianceProperty->setAttribute("minimum", 0);
varianceProperty->setAttribute("maximum", 100);
varianceProperty->setAttribute("singleStep", 0.05);
this->addParameter(varianceProperty);
addParameter(varianceProperty);
Property* upperThresholdProperty = new Property(tr("Upper threshold"), 0.0, tr("The upper threshold is used at step 3 to determine whether a voxel belongs an edge or not. \nAbove, the voxel is detected as an edge.\nBelow and upper the low threshold, the voxel is accepted if it is connected to an edge voxel neighbor."), "");
upperThresholdProperty->setAttribute("singleStep", 0.1);
this->addParameter(upperThresholdProperty);
addParameter(upperThresholdProperty);
Property* lowerThresholdProperty = new Property(tr("Lower threshold"), 0.0, tr("The lower threshold is used at step 3 to determine whether a voxel belongs an edge or not. \nAbove, and under the upper threshold the voxel is detected as an edge if it is connected to an edge voxel neighbor. \nBelow, the voxel is rejected."), "");
lowerThresholdProperty->setAttribute("singleStep", 0.1);
this->addParameter(lowerThresholdProperty);
addParameter(lowerThresholdProperty);
}
// --------------- destructor -------------------
......
......@@ -24,17 +24,24 @@
****************************************************************************/
#include "Derivative.h"
// CamiTK includes
#include <Application.h>
#include <ItkProgressObserver.h>
#include <QMessageBox>
#include <QString>
#include <QTextStream>
#include <itkImageToVTKImageFilter.h>
#include <itkVTKImageToImageFilter.h>
#include <ItkProgressObserver.h>
#include <Property.h>
// ITK includes
#include <itkImageToVTKImageFilter.h>
#include <itkVTKImageToImageFilter.h>
#include <itkCastImageFilter.h>
#include <itkRescaleIntensityImageFilter.h>
#include <itkDerivativeImageFilter.h>
// Qt includes
#include <QMessageBox>
#include <QString>
#include <QTextStream>
using namespace camitk;
......@@ -43,15 +50,19 @@ Derivative::Derivative(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("Partial Derivative");
setDescription("<br><b>This filter is used for computing the <i>partial derivative</i> of an image.</b><br>\
Choose the order of the derivative <br> \
(0) Zero order: no derivation, <br> \
(1) First order derivative <br> \
(2) Second order derivative, etc.<br> \
<br>\
Choose the direction of the derivative: <br> \
(0): Derivative along X axis <br> \
(1): Derivative along Y axis <br> \
(2): Derivative along Z axis <br>\
<br><br> \
Choose the order of the derivative:\
<ul> \
<li> Zero order: no derivation \
<li> First order derivative \
<li> Second order derivative \
</ul> \
Choose the direction of the derivative:\
<ul> \
<li> Derivative along X axis \
<li> Derivative along Y axis \
<li> Derivative along Z axis \
</ul> \
");
setComponent("ImageComponent");
......@@ -62,14 +73,22 @@ Derivative::Derivative(ActionExtension * extension) : Action(extension) {
this->addTag("Contours");
// Setting parameters default values
setProperty("keepOriginalImageVoxelType", QVariant(true));
setProperty("derivativeOrder", QVariant(1));
setProperty("direction", QVariant(0));
keepOrgVoxelType = true;
derivativeOrder = 1;
direction = 0;
Property* keepOrgVoxelTypeProperty = new Property(tr("Keep original voxel type?"), true, tr("Does the output image have the same voxel type as the input one?"), "");
addParameter(keepOrgVoxelTypeProperty);
Property* derivativeOrderProperty = new Property(tr("Derivative order"), ORDER_0, tr("The derivative order of the partial derivative along the selected direction (x, y, z)."), "");
derivativeOrderProperty->setEnumTypeName("derivativeOrder");
QStringList derivativeOrderValues;
derivativeOrderValues << "0th order: no derivation" << "1st order derivative" << "2nd order derivative";
derivativeOrderProperty->setAttribute("enumNames", derivativeOrderValues);
addParameter(derivativeOrderProperty);
Property* directionProperty = new Property(tr("Direction"), DIRECTION_X, tr("The direction of the partial derivative."), "");
directionProperty->setEnumTypeName("derivativeDirection");
QStringList directionValues;
directionValues << "Along X axis" << "Along Y axis" << "Along Z axis";
directionProperty->setAttribute("enumNames", directionValues);
addParameter(directionProperty);
}
// --------------- destructor -------------------
......@@ -81,27 +100,16 @@ Derivative::~Derivative() {
Action::ApplyStatus Derivative::apply() {
foreach (Component *comp, getTargets()) {
ImageComponent * input = dynamic_cast<ImageComponent *> ( comp );
process(input);
this->process(input);
}
return SUCCESS;
}
void Derivative::process(ImageComponent * comp) {
// Get the parameters
keepOrgVoxelType = property("keepOriginalImageVoxelType").toBool();
derivativeOrder = property("derivativeOrder").toInt();
direction = property("direction").toInt();
if (((derivativeOrder < 0) || (derivativeOrder > 5)) ||
((direction < 0) || (direction > 2 ))) {
QString msg;
QTextStream in(&msg);
in << "Derivative order should be positive and most reasonnably sammler to 5." << endl;
in << "direction should be 0 (x), 1 (y) or 2(z). " << endl;
QMessageBox::warning(NULL, "Action Called", msg);
return;
}
this->keepOrgVoxelType = property("Keep original voxel type?").toBool();
this->order = property("Derivative order").toInt();
this->direction = property("Direction").toInt();
// ITK filter implementation using templates
vtkSmartPointer<vtkImageData> inputImage = comp->getImageData();
......@@ -110,7 +118,6 @@ void Derivative::process(ImageComponent * comp) {
QTextStream(&newName) << comp->getName() << "_processed";
new ImageComponent(outputImage, newName);
Application::refresh();
}
#include "Derivative.impl"
......@@ -169,8 +176,8 @@ vtkSmartPointer<vtkImageData> Derivative::itkProcess(vtkSmartPointer<vtkImageDat
observer->Reset();
derivativeFilter->SetInput(toDoubleFilter->GetOutput());
derivativeFilter->SetOrder(derivativeOrder);
derivativeFilter->SetDirection(direction);
derivativeFilter->SetOrder(this->order);
derivativeFilter->SetDirection(this->direction);
derivativeFilter->AddObserver(itk::ProgressEvent(), observer);
derivativeFilter->Update();
observer->Reset();
......
......@@ -39,8 +39,19 @@
*
**/
class Derivative : public camitk::Action {
Q_OBJECT
/// Enumerations
Q_ENUMS( derivativeOrder )
Q_ENUMS( derivativeDirection )
public:
/// The 3 different possible derivative orders
enum derivativeOrder { ORDER_0, ORDER_1, ORDER_2 };
/// The direction of the derivative
enum derivativeDirection { DIRECTION_X, DIRECTION_Y, DIRECTION_Z };
/// Default Constructor
Derivative(camitk::ActionExtension *);
......@@ -82,7 +93,10 @@ protected:
int direction;
/// The order of the derivative.
int derivativeOrder;
int order;
};
Q_DECLARE_METATYPE(Derivative::derivativeOrder)
Q_DECLARE_METATYPE(Derivative::derivativeDirection)
#endif // DERIVATIVE_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment