Commit df0298df authored by saubatn's avatar saubatn

FEATURE 600 Reformat source code using Java style coding convention (by using...

FEATURE 600 Reformat source code using Java style coding convention (by using artistic style 'astyle' program).

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1904 ec899d31-69d1-42ba-9299-647d76f65fb3
parent a6e8ce68
......@@ -65,23 +65,23 @@ AnisotropicDiffusion::AnisotropicDiffusion(ActionExtension * extension) : Action
// Setting parameters default values by using properties
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. "), "");
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);
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."), "");
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);
addParameter(conductanceProperty);
Property* implementationProperty = new Property("Diffusion type", AnisotropicDiffusion::GRADIENT,
"The type of diffusion to use.", "");
"The type of diffusion to use.", "");
implementationProperty->setEnumTypeName("AnisoDiffType");
QStringList possibleValues;
possibleValues << "Gradient" << "Curvature";
......@@ -133,13 +133,13 @@ vtkSmartPointer<vtkImageData> AnisotropicDiffusion::itkProcess(vtkSmartPointer<v
vtkSmartPointer<vtkImageData> outputImage = vtkSmartPointer<vtkImageData>::New();
switch (this->getDiffusionType()) {
default:
case AnisotropicDiffusion::GRADIENT:
outputImage = itkProcessGradientAnisotropicDiffusion<InputPixelType, OutputPixelType, dim>(img);
break;
case AnisotropicDiffusion::CURVATURE:
outputImage = itkProcessCurvatureAnisotropicDiffusion<InputPixelType, OutputPixelType, dim>(img);
break;
default:
case AnisotropicDiffusion::GRADIENT:
outputImage = itkProcessGradientAnisotropicDiffusion<InputPixelType, OutputPixelType, dim>(img);
break;
case AnisotropicDiffusion::CURVATURE:
outputImage = itkProcessCurvatureAnisotropicDiffusion<InputPixelType, OutputPixelType, dim>(img);
break;
}
return outputImage;
......@@ -221,8 +221,7 @@ vtkSmartPointer<vtkImageData> AnisotropicDiffusion::itkProcessGradientAnisotropi
observer->Reset();
resultImage = itkToVtkOrgFilter->GetOutput();
}
else {
} else {
itkToVtkFloatFilter->SetInput(filter->GetOutput());
itkToVtkFloatFilter->AddObserver(itk::ProgressEvent(), observer);
itkToVtkFloatFilter->Update();
......@@ -319,8 +318,7 @@ vtkSmartPointer<vtkImageData> AnisotropicDiffusion::itkProcessCurvatureAnisotrop
observer->Reset();
resultImage = itkToVtkOrgFilter->GetOutput();
}
else {
} else {
itkToVtkFloatFilter->SetInput(filter->GetOutput());
itkToVtkFloatFilter->AddObserver(itk::ProgressEvent(), observer);
itkToVtkFloatFilter->Update();
......
......@@ -31,12 +31,12 @@
#include <ActionWidget.h>
/**
*
*
* @ingroup group_cepimaging_actions_itkfilters
*
*
* @brief
* Perform a anisotropic diffusion on the @ref camitk::ImageComponent "ImageComponent"
*
*
**/
class AnisotropicDiffusion : public camitk::Action {
Q_OBJECT
......
......@@ -183,8 +183,7 @@ vtkSmartPointer<vtkImageData> CannyEdgeDetection::itkProcess(vtkSmartPointer<vtk
observer->Reset();
// --------------------- Create and return a copy (the filters will be deleted)--
resultImage = itkToVtkFilter2->GetOutput();
}
else {
} else {
// From ITK to VTK
itkToVtkFilter->SetInput(cannyFilter->GetOutput());
itkToVtkFilter->AddObserver(itk::ProgressEvent(), observer);
......
......@@ -31,12 +31,12 @@
#include <ActionWidget.h>
/**
*
*
* @ingroup group_cepimaging_actions_itkfilters
*
*
* @brief
* Perform a connected component analysis on the @ref camitk::ImageComponent "ImageComponent"
*
*
**/
class ConnectedComponents : public camitk::Action {
Q_OBJECT
......
......@@ -25,7 +25,7 @@
#include "Derivative.h"
// CamiTK includes
#include <Application.h>
#include <Application.h>
#include <ItkProgressObserver.h>
#include <Property.h>
......@@ -47,7 +47,7 @@ using namespace camitk;
// --------------- constructor -------------------
Derivative::Derivative(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
// 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>\
<br><br> \
......@@ -66,7 +66,7 @@ Derivative::Derivative(ActionExtension * extension) : Action(extension) {
");
setComponent("ImageComponent");
// Setting classification family and tags
// Setting classification family and tags
this->setFamily("ITK Filter");
this->addTag("Derivative");
this->addTag("Edge Detection");
......@@ -111,109 +111,107 @@ void Derivative::process(ImageComponent * comp) {
this->order = property("Derivative order").toInt();
this->direction = property("Direction").toInt();
// ITK filter implementation using templates
vtkSmartPointer<vtkImageData> inputImage = comp->getImageData();
// ITK filter implementation using templates
vtkSmartPointer<vtkImageData> inputImage = comp->getImageData();
vtkSmartPointer<vtkImageData> outputImage = implementProcess (inputImage);
QString newName;
QTextStream(&newName) << comp->getName() << "_processed";
QString newName;
QTextStream(&newName) << comp->getName() << "_processed";
new ImageComponent(outputImage, newName);
Application::refresh();
Application::refresh();
}
#include "Derivative.impl"
#include "Derivative.impl"
// ITK filter implementation
template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> Derivative::itkProcess(vtkSmartPointer<vtkImageData> img)
{
vtkSmartPointer<vtkImageData> result = vtkSmartPointer<vtkImageData>::New();
vtkSmartPointer<vtkImageData> resultImage;
// --------------------- Filters declaration and creation ----------------------
// Define ITK input and output image types with respect to the instanciation
// types of the tamplate.
typedef itk::Image< InputPixelType, dim > InputImageType;
typedef itk::Image< OutputPixelType, dim > OutputImageType;
// Convert the image from CamiTK in VTK format to ITK format to use ITK filters.
typedef itk::VTKImageToImageFilter<InputImageType> vtkToItkFilterType;
template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> Derivative::itkProcess(vtkSmartPointer<vtkImageData> img) {
vtkSmartPointer<vtkImageData> result = vtkSmartPointer<vtkImageData>::New();
vtkSmartPointer<vtkImageData> resultImage;
// --------------------- Filters declaration and creation ----------------------
// Define ITK input and output image types with respect to the instanciation
// types of the tamplate.
typedef itk::Image< InputPixelType, dim > InputImageType;
typedef itk::Image< OutputPixelType, dim > OutputImageType;
// Convert the image from CamiTK in VTK format to ITK format to use ITK filters.
typedef itk::VTKImageToImageFilter<InputImageType> vtkToItkFilterType;
typename vtkToItkFilterType::Pointer vtkToItkFilter = vtkToItkFilterType::New();
// Declare and create your own private ITK filter here...
typedef itk::CastImageFilter<InputImageType, OutputImageType> CastFilterType;
typename CastFilterType::Pointer toDoubleFilter = CastFilterType::New();
// Declare and create your own private ITK filter here...
typedef itk::CastImageFilter<InputImageType, OutputImageType> CastFilterType;
typename CastFilterType::Pointer toDoubleFilter = CastFilterType::New();
typedef itk::DerivativeImageFilter<OutputImageType, OutputImageType> DerivativeFilterType;
typename DerivativeFilterType::Pointer derivativeFilter = DerivativeFilterType::New();
typedef itk::DerivativeImageFilter<OutputImageType, OutputImageType> DerivativeFilterType;
typename DerivativeFilterType::Pointer derivativeFilter = DerivativeFilterType::New();
typedef itk::RescaleIntensityImageFilter<OutputImageType, InputImageType> ToOrgFilterType;
typename ToOrgFilterType::Pointer toOrgFilter = ToOrgFilterType::New();
typedef itk::RescaleIntensityImageFilter<OutputImageType, InputImageType> ToOrgFilterType;
typename ToOrgFilterType::Pointer toOrgFilter = ToOrgFilterType::New();
// In the same way, once the image is filtered, we need to convert it again to
// VTK format to give it to CamiTK.
typedef itk::ImageToVTKImageFilter<OutputImageType> ItkToVtkFloatFilterType;
typename ItkToVtkFloatFilterType::Pointer itkToVtkFloatFilter = ItkToVtkFloatFilterType::New();
// In the same way, once the image is filtered, we need to convert it again to
// VTK format to give it to CamiTK.
typedef itk::ImageToVTKImageFilter<OutputImageType> ItkToVtkFloatFilterType;
typename ItkToVtkFloatFilterType::Pointer itkToVtkFloatFilter = ItkToVtkFloatFilterType::New();
typedef itk::ImageToVTKImageFilter<InputImageType> ItkToVtkOrgFilterType;
typename ItkToVtkOrgFilterType::Pointer itkToVtkOrgFilter = ItkToVtkOrgFilterType::New();
typedef itk::ImageToVTKImageFilter<InputImageType> ItkToVtkOrgFilterType;
typename ItkToVtkOrgFilterType::Pointer itkToVtkOrgFilter = ItkToVtkOrgFilterType::New();
// To update CamiTK progress bar while filtering, add an ITK observer to the filters.
ItkProgressObserver::Pointer observer = ItkProgressObserver::New();
// ITK observers generally give values between 0 and 1, and CamiTK progress bar
// To update CamiTK progress bar while filtering, add an ITK observer to the filters.
ItkProgressObserver::Pointer observer = ItkProgressObserver::New();
// ITK observers generally give values between 0 and 1, and CamiTK progress bar
// wants values between 0 and 100...
observer->SetCoef(100.0);
observer->SetCoef(100.0);
// --------------------- Plug filters and parameters ---------------------------
// From VTK to ITK
vtkToItkFilter->SetInput(img);
vtkToItkFilter->AddObserver(itk::ProgressEvent(), observer);
vtkToItkFilter->Update();
observer->Reset();
// --------------------- Plug filters and parameters ---------------------------
// From VTK to ITK
vtkToItkFilter->SetInput(img);
vtkToItkFilter->AddObserver(itk::ProgressEvent(), observer);
vtkToItkFilter->Update();
observer->Reset();
toDoubleFilter->SetInput(vtkToItkFilter->GetOutput());
toDoubleFilter->AddObserver(itk::ProgressEvent(), observer);
toDoubleFilter->Update();
observer->Reset();
toDoubleFilter->SetInput(vtkToItkFilter->GetOutput());
toDoubleFilter->AddObserver(itk::ProgressEvent(), observer);
toDoubleFilter->Update();
observer->Reset();
derivativeFilter->SetInput(toDoubleFilter->GetOutput());
derivativeFilter->SetInput(toDoubleFilter->GetOutput());
derivativeFilter->SetOrder(this->order);
derivativeFilter->SetDirection(this->direction);
derivativeFilter->AddObserver(itk::ProgressEvent(), observer);
derivativeFilter->Update();
observer->Reset();
if (keepOrgVoxelType) {
toOrgFilter->SetInput(derivativeFilter->GetOutput());
toOrgFilter->AddObserver(itk::ProgressEvent(), observer);
toOrgFilter->Update();
observer->Reset();
itkToVtkOrgFilter->SetInput(toOrgFilter->GetOutput());
itkToVtkOrgFilter->AddObserver(itk::ProgressEvent(), observer);
itkToVtkOrgFilter->Update();
observer->Reset();
resultImage = itkToVtkOrgFilter->GetOutput();
}
else {
itkToVtkFloatFilter->SetInput(derivativeFilter->GetOutput());
itkToVtkFloatFilter->AddObserver(itk::ProgressEvent(), observer);
itkToVtkFloatFilter->Update();
observer->Reset();
resultImage = itkToVtkFloatFilter->GetOutput();
}
derivativeFilter->AddObserver(itk::ProgressEvent(), observer);
derivativeFilter->Update();
observer->Reset();