Commit e14b0774 authored by saubatn's avatar saubatn
Browse files

FEATURE 193 Canny Edge Detection properties updated.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1611 ec899d31-69d1-42ba-9299-647d76f65fb3
parent b6d49c17
......@@ -22,13 +22,19 @@
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#include "CannyEdgeDetection.h"
// CamiTK includes
#include "CannyEdgeDetection.h"
#include <Application.h>
#include <ItkProgressObserver.h>
#include <Property.h>
// Qt includes
#include <QMessageBox>
#include <QString>
#include <QTextStream>
// ITK includes
#include <ItkProgressObserver.h>
#include <itkImageToVTKImageFilter.h>
#include <itkVTKImageToImageFilter.h>
#include <itkCastImageFilter.h>
......@@ -41,10 +47,9 @@ using namespace camitk;
// --------------- constructor -------------------
CannyEdgeDetection::CannyEdgeDetection(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("Canny Edge Detecton");
setDescription("<br>The <b> <i>Canny edge detector</i> </b> is an edge detection operator that uses a multi-stage algorithm to detect a wide range of edges in images. <br> \
It was developed by John F. Canny in 1986. <i>(source: Wikipedia)</i>.<br> \
This filter is widely used for edge detection since it is the optimal solution satisfying the constraints of good sensitivity, localization and noise robustness. <i>(source: ITK Developer's Guide)</i>.<br> ");
setName("Canny Edge Detection");
setDescription("<br>The <b> <i>Canny edge detector</i> </b> is an edge detection operator that uses a multi-stage algorithm to detect a wide range of edges in images. <br> \n The filter steps are : \n * Preprocessing noise reduction using a gaussian convolution filtering. \n * Finding the intensity gradient of the image \n * Non-maximum suppression \n * Tracing edges through the image and hysteresis thresholding \n It was developed by John F. Canny in 1986. <i>(source: Wikipedia)</i>.<br> \n This filter is widely used for edge detection since it is the optimal solution satisfying the constraints of good sensitivity, localization and noise robustness. <i>(source: ITK Developer's Guide)</i>.<br> ");
setComponent("ImageComponent");
// Setting classification family and tags
......@@ -54,11 +59,22 @@ CannyEdgeDetection::CannyEdgeDetection(ActionExtension * extension) : Action(ext
this->addTag("Contours");
// Setting parameters default values
setProperty("keepOriginalImageVoxelType", QVariant(true));
setProperty("variance", QVariant(2.0));
setProperty("upperThreshold", QVariant(0.0));
setProperty("lowerThreshold", QVariant(0.0));
keepOrgVoxelType = true;
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);
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);
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);
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);
}
// --------------- destructor -------------------
......@@ -77,10 +93,10 @@ Action::ApplyStatus CannyEdgeDetection::apply() {
void CannyEdgeDetection::process(ImageComponent * comp) {
// Get the parameters
keepOrgVoxelType = property("keepOriginalImageVoxelType").toBool();
variance = property("variance").toDouble();
upperThreshold = property("upperThreshold").toDouble();
lowerThreshold = property("lowerThreshold").toDouble();
keepOrgVoxelType = property("Keep original voxel type?").toBool();
variance = property("Variance").toDouble();
upperThreshold = property("Upper threshold").toDouble();
lowerThreshold = property("Lower threshold").toDouble();
// ITK filter implementation using templates
vtkSmartPointer<vtkImageData> inputImage = comp->getImageData();
vtkSmartPointer<vtkImageData> outputImage = implementProcess (inputImage);
......
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