Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit a5a3916f authored by saubatn's avatar saubatn
Browse files

FEATURE 193 Properties updated.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1620 ec899d31-69d1-42ba-9299-647d76f65fb3
parent ddeb2a2a
......@@ -22,13 +22,18 @@
*
* $CAMITK_LICENCE_END$
****************************************************************************/
// CamiTK includes
#include "MorphologicalOperators.h"
#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 <itkBinaryBallStructuringElement.h>
......@@ -44,7 +49,7 @@ using namespace camitk;
MorphologicalOperators::MorphologicalOperators(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("Morphological Operators");
setDescription("<br><b>Mathematical morphology</b> has proved to be a powerful resource for image processing and analysis. This filter implements classical mathematical morphology operators:<br>\
setDescription("<br/><b>Mathematical morphology</b> has proved to be a powerful resource for image processing and analysis.<br/><br/>This filter implements classical mathematical morphology operators:\
<ul><li>erosion</li><li>dilation</li><li>opening</li><li>closure</li></ul>");
setComponent("ImageComponent");
......@@ -56,9 +61,25 @@ MorphologicalOperators::MorphologicalOperators(ActionExtension * extension) : Ac
this->addTag("Neighborhood Filter");
// Setting parameters default values
setProperty("structuringElementSize", QVariant(1));
this->typeOfOperation = Grey_Level;
this->operation = Erosion;
Property* structuringElementSizeProperty = new Property(tr("Structuring element size"), 1, tr("The structuring element size 'n'' represents the dimension of the n x n x n voxels square used by the operator.\nFor instance a 3 voxels size will indicate a 3x3x3 square."), "");
structuringElementSizeProperty->setAttribute("minimum", 1);
structuringElementSizeProperty->setAttribute("maximum", 100);
structuringElementSizeProperty->setAttribute("singleStep", 1);
addParameter(structuringElementSizeProperty);
Property* morphoTypeProperty = new Property(tr("Image scalar type"), GREY_LEVEL, tr("The image scalar type."), "");
morphoTypeProperty->setEnumTypeName("MorphoType");
QStringList morphoTypeNames;
morphoTypeNames << "Grey level" << "Binary";
morphoTypeProperty->setAttribute("enumNames", morphoTypeNames);
addParameter(morphoTypeProperty);
Property* morphoOperationProperty = new Property(tr("Type of operation"), EROSION, tr("Select the desired morphological operation."), "");
morphoOperationProperty->setEnumTypeName("MorphoOperation");
QStringList morphoOperationNames;
morphoOperationNames << "Erosion" << "Dilation" << "Opening" << "Closing";
morphoOperationProperty->setAttribute("enumNames", morphoOperationNames);
addParameter(morphoOperationProperty);
}
// --------------- destructor -------------------
......@@ -66,21 +87,12 @@ MorphologicalOperators::~MorphologicalOperators() {
// 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)
}
MorphologicalOperators::MorphoType MorphologicalOperators::getTypeOfOperation() const {
return typeOfOperation;
}
void MorphologicalOperators::setTypeOfOperation(const MorphoType typeOfOperation) {
this->typeOfOperation = typeOfOperation;
}
MorphologicalOperators::MorphoOperation MorphologicalOperators::getOperation() const {
return operation;
MorphologicalOperators::MorphoType MorphologicalOperators::getMorphoType() const {
return (MorphoType) property("Image scalar type").toInt();
}
void MorphologicalOperators::setOperation(const MorphoOperation operation) {
this->operation = operation;
MorphologicalOperators::MorphoOperation MorphologicalOperators::getMorphoOperation() const {
return (MorphoOperation) property("Type of operation").toInt();
}
// --------------- apply -------------------
......@@ -94,7 +106,7 @@ Action::ApplyStatus MorphologicalOperators::apply() {
void MorphologicalOperators::process(ImageComponent * comp) {
// Get the parameters
structuringElementSize = property("structuringElementSize").toInt();
this->structuringElementSize = property("Structuring element size").toInt();
// ITK filter implementation using templates
vtkSmartPointer<vtkImageData> inputImage = comp->getImageData();
......@@ -113,24 +125,24 @@ template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> MorphologicalOperators::itkProcess(vtkSmartPointer<vtkImageData> img) {
vtkSmartPointer<vtkImageData> result;
switch (getTypeOfOperation()) {
switch (this->getMorphoType()) {
case MorphologicalOperators::Grey_Level:
case MorphologicalOperators::GREY_LEVEL:
switch (getOperation()) {
case MorphologicalOperators::Erosion:
switch (this->getMorphoOperation()) {
case MorphologicalOperators::EROSION:
suffix = "_eroded";
result = greyLevelErosionFilter<InputPixelType, OutputPixelType, dim>(img);
break;
case MorphologicalOperators::Dilation:
case MorphologicalOperators::DILATION:
suffix = "_dilated";
result = greyLevelDilationFilter<InputPixelType, OutputPixelType, dim>(img);
break;
case MorphologicalOperators::Opening:
case MorphologicalOperators::OPENING:
suffix = "_opened";
result = greyLevelOpeningFilter<InputPixelType, OutputPixelType, dim>(img);
break;
case MorphologicalOperators::Closing:
case MorphologicalOperators::CLOSING:
suffix = "_closed";
result = greyLevelClosureFilter<InputPixelType, OutputPixelType, dim>(img);
break;
......@@ -139,22 +151,22 @@ vtkSmartPointer<vtkImageData> MorphologicalOperators::itkProcess(vtkSmartPointer
}
break;
case MorphologicalOperators::Binary:
case MorphologicalOperators::BINARY:
switch (getOperation()) {
case MorphologicalOperators::Erosion:
switch (this->getMorphoOperation()) {
case MorphologicalOperators::EROSION:
suffix = "_eroded";
result = binaryErosionFilter<InputPixelType, OutputPixelType, dim>(img);
break;
case MorphologicalOperators::Dilation:
case MorphologicalOperators::DILATION:
suffix = "_dilated";
result = binaryDilationFilter<InputPixelType, OutputPixelType, dim>(img);
break;
case MorphologicalOperators::Opening:
case MorphologicalOperators::OPENING:
suffix = "_opened";
result = binaryOpeningFilter<InputPixelType, OutputPixelType, dim>(img);
break;
case MorphologicalOperators::Closing:
case MorphologicalOperators::CLOSING:
suffix = "_closed";
result = binaryClosureFilter<InputPixelType, OutputPixelType, dim>(img);
break;
......
......@@ -47,26 +47,21 @@ class MorphologicalOperators : public camitk::Action {
Q_ENUMS( MorphoType )
Q_ENUMS( MorphoOperation )
Q_PROPERTY( MorphoType typeOfOperation READ getTypeOfOperation WRITE setTypeOfOperation)
Q_PROPERTY( MorphoOperation operation READ getOperation WRITE setOperation)
public:
/// Define the possible types of morphological operatiosn
enum MorphoType {Grey_Level, Binary };
/// Define the possible types of morphological operations
enum MorphoType {GREY_LEVEL, BINARY};
/// Define the possible morphological operations
enum MorphoOperation {Erosion, Dilation, Opening, Closing };
enum MorphoOperation {EROSION, DILATION, OPENING, CLOSING};
/// Default Constructor
MorphologicalOperators(camitk::ActionExtension *);
// Setters and Getters for parameters
MorphoType getTypeOfOperation() const ;
void setTypeOfOperation(const MorphoType typeOfOperation);
/// Get the morphological type of operation
MorphoType getMorphoType() const ;
MorphoOperation getOperation() const ;
void setOperation(const MorphoOperation operation);
/// Get the morphological operation selected
MorphoOperation getMorphoOperation() const ;
/// Default Destructor
virtual ~MorphologicalOperators();
......@@ -119,4 +114,7 @@ protected:
QString suffix;
};
Q_DECLARE_METATYPE(MorphologicalOperators::MorphoType)
Q_DECLARE_METATYPE(MorphologicalOperators::MorphoOperation)
#endif // MORPHOLOGICALOPERATORS_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