Commit b4e75674 authored by saubatn's avatar saubatn
Browse files

FEATURE 193 Gaussian filter properties updated.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1614 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 6b11504e
...@@ -24,11 +24,17 @@ ...@@ -24,11 +24,17 @@
****************************************************************************/ ****************************************************************************/
#include "GaussianFilter.h" #include "GaussianFilter.h"
// CamiTK includes
#include <Application.h> #include <Application.h>
#include <ItkProgressObserver.h> #include <ItkProgressObserver.h>
#include <Property.h>
// Qt includes
#include <QMessageBox> #include <QMessageBox>
#include <QString> #include <QString>
#include <QTextStream> #include <QTextStream>
// ITK includes
#include <itkImageToVTKImageFilter.h> #include <itkImageToVTKImageFilter.h>
#include <itkVTKImageToImageFilter.h> #include <itkVTKImageToImageFilter.h>
#include <itkCastImageFilter.h> #include <itkCastImageFilter.h>
...@@ -55,9 +61,18 @@ GaussianFilter::GaussianFilter(ActionExtension * extension) : Action(extension) ...@@ -55,9 +61,18 @@ GaussianFilter::GaussianFilter(ActionExtension * extension) : Action(extension)
this->addTag("Gaussian"); this->addTag("Gaussian");
// Setting parameters default values // Setting parameters default values
setProperty("variance", QVariant(1.0)); Property* varianceProperty = new Property(tr("Variance"), 1.0, tr("The variance is an input parameter of the gaussian kernel. \nThe higher the variance is, the blurer the resulting image will be."), "");
this->variance = 1.0; varianceProperty->setAttribute("minimum", 0);
this->implementation = Standard; varianceProperty->setAttribute("maximum", 100);
varianceProperty->setAttribute("singleStep", 0.05);
addParameter(varianceProperty);
Property* gaussianTypeProperty = new Property(tr("Gaussian Type"), STANDARD, tr("Choose the type of kernel for the gaussian filtering"), "");
gaussianTypeProperty->setEnumTypeName("GaussianType");
QStringList gaussianTypeValue;
gaussianTypeValue << tr("Standard") << tr("Recursive IIR");
gaussianTypeProperty->setAttribute("enumNames", gaussianTypeValue);
addParameter(gaussianTypeProperty);
} }
// --------------- destructor ------------------- // --------------- destructor -------------------
...@@ -65,13 +80,10 @@ GaussianFilter::~GaussianFilter() { ...@@ -65,13 +80,10 @@ GaussianFilter::~GaussianFilter() {
// do not delete the widget has it might have been used in the ActionViewer (i.e. the ownership might have been taken by the stacked widget) // do not delete the widget has it might have been used in the ActionViewer (i.e. the ownership might have been taken by the stacked widget)
} }
GaussianFilter::GaussianType GaussianFilter::getMethod() { GaussianFilter::GaussianType GaussianFilter::getType() {
return this->implementation; return (GaussianFilter::GaussianType) property("Gaussian Type").toInt();
} }
void GaussianFilter::setMethod(GaussianFilter::GaussianType implementation) {
this->implementation = implementation;
}
// --------------- apply ------------------- // --------------- apply -------------------
Action::ApplyStatus GaussianFilter::apply() { Action::ApplyStatus GaussianFilter::apply() {
...@@ -84,7 +96,7 @@ Action::ApplyStatus GaussianFilter::apply() { ...@@ -84,7 +96,7 @@ Action::ApplyStatus GaussianFilter::apply() {
void GaussianFilter::process(ImageComponent * comp) { void GaussianFilter::process(ImageComponent * comp) {
// Get the parameters // Get the parameters
variance = property("variance").toDouble(); this->variance = property("Variance").toDouble();
// ITK filter implementation using templates // ITK filter implementation using templates
vtkSmartPointer<vtkImageData> inputImage = comp->getImageData(); vtkSmartPointer<vtkImageData> inputImage = comp->getImageData();
...@@ -105,13 +117,13 @@ vtkSmartPointer<vtkImageData> GaussianFilter::itkProcess(vtkSmartPointer<vtkImag ...@@ -105,13 +117,13 @@ vtkSmartPointer<vtkImageData> GaussianFilter::itkProcess(vtkSmartPointer<vtkImag
{ {
vtkSmartPointer<vtkImageData> outputImage = vtkSmartPointer<vtkImageData>::New(); vtkSmartPointer<vtkImageData> outputImage = vtkSmartPointer<vtkImageData>::New();
switch (getMethod()) switch (this->getType())
{ {
default: default:
case GaussianFilter::Standard: case GaussianFilter::STANDARD:
outputImage = itkProcessStandardGaussian<InputPixelType, OutputPixelType, dim>(img); outputImage = itkProcessStandardGaussian<InputPixelType, OutputPixelType, dim>(img);
break; break;
case GaussianFilter::Recursive_IIR: case GaussianFilter::RECURSIVE_IIR:
outputImage = itkProcessIIRGaussian<InputPixelType, OutputPixelType, dim>(img); outputImage = itkProcessIIRGaussian<InputPixelType, OutputPixelType, dim>(img);
break; break;
} }
......
...@@ -44,12 +44,10 @@ class GaussianFilter : public camitk::Action { ...@@ -44,12 +44,10 @@ class GaussianFilter : public camitk::Action {
/// Enumerations /// Enumerations
Q_ENUMS( GaussianType ) Q_ENUMS( GaussianType )
Q_PROPERTY( GaussianType implementation READ getMethod WRITE setMethod)
public: public:
/// Define the possible implementations of Gaussian filtering /// Define the possible implementations of Gaussian filtering
enum GaussianType {Standard, Recursive_IIR }; enum GaussianType {STANDARD, RECURSIVE_IIR };
/// Default Constructor /// Default Constructor
GaussianFilter(camitk::ActionExtension *); GaussianFilter(camitk::ActionExtension *);
...@@ -65,8 +63,11 @@ public slots: ...@@ -65,8 +63,11 @@ public slots:
*/ */
virtual ApplyStatus apply(); virtual ApplyStatus apply();
GaussianType getMethod(); /**
void setMethod(GaussianType implementation); * @brief Get the type of gaussian filering, between Standard and Recursive.
* @return The user selected gaussian filtering type.
*/
GaussianType getType();
private: private:
/// helper method to simplify the target component processing /// helper method to simplify the target component processing
...@@ -85,7 +86,8 @@ private: ...@@ -85,7 +86,8 @@ private:
protected: protected:
GaussianType implementation;
double variance; double variance;
}; };
Q_DECLARE_METATYPE(GaussianFilter::GaussianType)
#endif // DISCRETEGAUSSIANFILTER_H #endif // DISCRETEGAUSSIANFILTER_H
Supports Markdown
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