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 @@
****************************************************************************/
#include "GaussianFilter.h"
// CamiTK includes
#include <Application.h>
#include <ItkProgressObserver.h>
#include <Property.h>
// Qt includes
#include <QMessageBox>
#include <QString>
#include <QTextStream>
// ITK includes
#include <itkImageToVTKImageFilter.h>
#include <itkVTKImageToImageFilter.h>
#include <itkCastImageFilter.h>
......@@ -55,9 +61,18 @@ GaussianFilter::GaussianFilter(ActionExtension * extension) : Action(extension)
this->addTag("Gaussian");
// Setting parameters default values
setProperty("variance", QVariant(1.0));
this->variance = 1.0;
this->implementation = Standard;
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."), "");
varianceProperty->setAttribute("minimum", 0);
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 -------------------
......@@ -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)
}
GaussianFilter::GaussianType GaussianFilter::getMethod() {
return this->implementation;
GaussianFilter::GaussianType GaussianFilter::getType() {
return (GaussianFilter::GaussianType) property("Gaussian Type").toInt();
}
void GaussianFilter::setMethod(GaussianFilter::GaussianType implementation) {
this->implementation = implementation;
}
// --------------- apply -------------------
Action::ApplyStatus GaussianFilter::apply() {
......@@ -84,7 +96,7 @@ Action::ApplyStatus GaussianFilter::apply() {
void GaussianFilter::process(ImageComponent * comp) {
// Get the parameters
variance = property("variance").toDouble();
this->variance = property("Variance").toDouble();
// ITK filter implementation using templates
vtkSmartPointer<vtkImageData> inputImage = comp->getImageData();
......@@ -105,13 +117,13 @@ vtkSmartPointer<vtkImageData> GaussianFilter::itkProcess(vtkSmartPointer<vtkImag
{
vtkSmartPointer<vtkImageData> outputImage = vtkSmartPointer<vtkImageData>::New();
switch (getMethod())
switch (this->getType())
{
default:
case GaussianFilter::Standard:
case GaussianFilter::STANDARD:
outputImage = itkProcessStandardGaussian<InputPixelType, OutputPixelType, dim>(img);
break;
case GaussianFilter::Recursive_IIR:
case GaussianFilter::RECURSIVE_IIR:
outputImage = itkProcessIIRGaussian<InputPixelType, OutputPixelType, dim>(img);
break;
}
......
......@@ -44,12 +44,10 @@ class GaussianFilter : public camitk::Action {
/// Enumerations
Q_ENUMS( GaussianType )
Q_PROPERTY( GaussianType implementation READ getMethod WRITE setMethod)
public:
/// Define the possible implementations of Gaussian filtering
enum GaussianType {Standard, Recursive_IIR };
enum GaussianType {STANDARD, RECURSIVE_IIR };
/// Default Constructor
GaussianFilter(camitk::ActionExtension *);
......@@ -65,8 +63,11 @@ public slots:
*/
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:
/// helper method to simplify the target component processing
......@@ -85,7 +86,8 @@ private:
protected:
GaussianType implementation;
double variance;
};
Q_DECLARE_METATYPE(GaussianFilter::GaussianType)
#endif // DISCRETEGAUSSIANFILTER_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