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 df0298df authored by saubatn's avatar saubatn
Browse files

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();
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();
}
// --------------------- Create and return a copy (the filters will be deleted)--
int extent[6];
resultImage->GetExtent(extent);
result->SetExtent(extent);
result->DeepCopy(resultImage);
result->Update();
resultImage->GetExtent(extent);
result->SetExtent(extent);
result->DeepCopy(resultImage);
result->Update();
// Set CamiTK progress bar back to zero (the processing filter is over)
// Set CamiTK progress bar back to zero (the processing filter is over)
observer->Reset();
return result;
}
return result;
}
......@@ -31,12 +31,12 @@
#include <ActionWidget.h>
/**
*
*
* @ingroup group_cepimaging_actions_itkfilters
*
*
* @brief
* Perform a derivative filter on the @ref camitk::ImageComponent "ImageComponent"
*
*
**/
class Derivative : public camitk::Action {
Q_OBJECT
......
......@@ -25,18 +25,18 @@
#include "GaussianFilter.h"
// CamiTK includes
#include <Application.h>
#include <ItkProgressObserver.h>
#include <Application.h>
#include <ItkProgressObserver.h>
#include <Property.h>
// Qt includes
#include <QMessageBox>
#include <QString>
#include <QTextStream>
#include <QMessageBox>
#include <QString>
#include <QTextStream>
// ITK includes
#include <itkImageToVTKImageFilter.h>
#include <itkVTKImageToImageFilter.h>
#include <itkImageToVTKImageFilter.h>
#include <itkVTKImageToImageFilter.h>
#include <itkCastImageFilter.h>
#include <itkRescaleIntensityImageFilter.h>
#include <itkDiscreteGaussianImageFilter.h>
......@@ -47,12 +47,12 @@ using namespace camitk;
// --------------- constructor -------------------
GaussianFilter::GaussianFilter(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
// Setting name, description and input component
setName("Gaussian Filter");
setDescription("<p>Blurring is the traditional apporach for removing noise from images. It is usually implemented in the form of a convolution with a kernel. One of the most commonly used kernels is the Gaussian.</p><p>The classical methode of smoothing an image by convolution with a Gaussian kernel has the drawback that it is slow when the standard deviation sigma of the Gaussian is large.</p><p>The Recursive IIR (Infinite Impulse Rewponse) implements an approximation of convolution with the Gaussian. In practice, this filter requires a constant number of operations for approximating the convolution, regardless of the sigma value.</p>");
setComponent("ImageComponent");
// Setting classification family and tags
// Setting classification family and tags
this->setFamily("ITK Filter");
this->addTag("Blur");
this->addTag("Smoothing");
......@@ -89,7 +89,7 @@ GaussianFilter::GaussianType GaussianFilter::getType() {
Action::ApplyStatus GaussianFilter::apply() {
foreach (Component *comp, getTargets()) {
ImageComponent * input = dynamic_cast<ImageComponent *> ( comp );
process(input);
process(input);
}
return SUCCESS;
}
......@@ -98,220 +98,216 @@ void GaussianFilter::process(ImageComponent * comp) {
// Get the parameters
this->variance = property("Variance").toDouble();
// ITK filter implementation using templates
vtkSmartPointer<vtkImageData> inputImage = comp->getImageData();
vtkSmartPointer<vtkImageData> outputImage = implementProcess(inputImage);
QString newName;
QTextStream(&newName) << comp->getName() << "_gaussian";
// ITK filter implementation using templates
vtkSmartPointer<vtkImageData> inputImage = comp->getImageData();
vtkSmartPointer<vtkImageData> outputImage = implementProcess(inputImage);
QString newName;
QTextStream(&newName) << comp->getName() << "_gaussian";
new ImageComponent(outputImage, newName);
Application::refresh();
Application::refresh();
}
#include "GaussianFilter.impl"
#include "GaussianFilter.impl"
// ITK filter implementation
template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> GaussianFilter::itkProcess(vtkSmartPointer<vtkImageData> img)
{
vtkSmartPointer<vtkImageData> outputImage = vtkSmartPointer<vtkImageData>::New();
switch (this->getType())
{
default:
template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> GaussianFilter::itkProcess(vtkSmartPointer<vtkImageData> img) {
vtkSmartPointer<vtkImageData> outputImage = vtkSmartPointer<vtkImageData>::New();
switch (this->getType()) {
default:
case GaussianFilter::STANDARD:
outputImage = itkProcessStandardGaussian<InputPixelType, OutputPixelType, dim>(img);
break;
outputImage = itkProcessStandardGaussian<InputPixelType, OutputPixelType, dim>(img);
break;
case GaussianFilter::RECURSIVE_IIR:
outputImage = itkProcessIIRGaussian<InputPixelType, OutputPixelType, dim>(img);
break;
}
return outputImage;
outputImage = itkProcessIIRGaussian<InputPixelType, OutputPixelType, dim>(img);
break;
}
return outputImage;
}
template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> GaussianFilter::itkProcessStandardGaussian(vtkSmartPointer<vtkImageData> img)
{
// --------------------- 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;
typedef itk::Image< double, dim > ComputeImageType;
// 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();
// 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> itkToVtkFilterType;
typename itkToVtkFilterType::Pointer itkToVtkFilter = itkToVtkFilterType::New();
// Declare and create your own private ITK filter here...
// Cast image
typedef itk::CastImageFilter<InputImageType, ComputeImageType> CastFilterType;
typename CastFilterType::Pointer castFilter = CastFilterType::New();
// Perform actual filtering (here should be your piece of code)
typedef itk::DiscreteGaussianImageFilter<ComputeImageType, ComputeImageType> FilterType;
typename FilterType::Pointer filter = FilterType::New();
// Re-cast to original pixel type
typedef itk::RescaleIntensityImageFilter<ComputeImageType, OutputImageType> RescaleFilterType;
typename RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New();
// To update CamiTK progress bar while filtering, add an ITK observer to the filters.
// Create a timer for the progress bar
ItkProgressObserver::Pointer observerCast = ItkProgressObserver::New();
ItkProgressObserver::Pointer observerBlur = ItkProgressObserver::New();
ItkProgressObserver::Pointer observerRescale = ItkProgressObserver::New();
observerCast->SetCoef(33.3);
observerCast->SetStartValue(0.0);
observerBlur->SetCoef(333.3);
observerBlur->SetStartValue(33.3);
observerRescale->SetCoef(33.3);
observerRescale->SetStartValue(66.6);
// --------------------- Plug filters and parameters ---------------------------
// From VTK to ITK
vtkToItkFilter->SetInput(img);
// For the filter itself
castFilter->SetInput(vtkToItkFilter->GetOutput());
castFilter->AddObserver( itk::ProgressEvent(), observerCast );
filter->SetInput( castFilter->GetOutput());
filter->AddObserver( itk::ProgressEvent(), observerBlur );
filter->SetVariance( this->variance );
rescaleFilter->SetInput(filter->GetOutput());
rescaleFilter->AddObserver( itk::ProgressEvent(), observerRescale );
// From ITK to VTK
itkToVtkFilter->SetInput(rescaleFilter->GetOutput());
// --------------------- Actually execute all filters parts --------------------
itkToVtkFilter->Update();
// --------------------- Create and return a copy (the filters will be deleted)--
vtkSmartPointer<vtkImageData> resultImage = itkToVtkFilter->GetOutput();
vtkSmartPointer<vtkImageData> result = vtkSmartPointer<vtkImageData>::New();
result = vtkImageData::New();
int extent[6];
resultImage->GetExtent(extent);
result->SetExtent(extent);
result->DeepCopy(resultImage);
result->Update();
observerCast->Reset();
observerBlur->Reset();
observerRescale->Reset();
return result;
template <class InputPixelType, class OutputPixelType, const int dim>
vtkSmartPointer<vtkImageData> GaussianFilter::itkProcessStandardGaussian(vtkSmartPointer<vtkImageData> img) {
// --------------------- 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;
typedef itk::Image< double, dim > ComputeImageType;
// 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();
// 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> itkToVtkFilterType;
typename itkToVtkFilterType::Pointer itkToVtkFilter = itkToVtkFilterType::New();
// Declare and create your own private ITK filter here...
// Cast image
typedef itk::CastImageFilter<InputImageType, ComputeImageType> CastFilterType;
typename CastFilterType::Pointer castFilter = CastFilterType::New();
// Perform actual filtering (here should be your piece of code)
typedef itk::DiscreteGaussianImageFilter<ComputeImageType, ComputeImageType> FilterType;
typename FilterType::Pointer filter = FilterType::New();
// Re-cast to original pixel type
typedef itk::RescaleIntensityImageFilter<ComputeImageType, OutputImageType> RescaleFilterType;
typename RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New();
// To update CamiTK progress bar while filtering, add an ITK observer to the filters.
// Create a timer for the progress bar
ItkProgressObserver::Pointer observerCast = ItkProgressObserver::New();
ItkProgressObserver::Pointer observerBlur = ItkProgressObserver::New();
ItkProgressObserver::Pointer observerRescale = ItkProgressObserver::New();
observerCast->SetCoef(33.3);
observerCast->SetStartValue(0.0);
observerBlur->SetCoef(333.3);
observerBlur->SetStartValue(33.3);
observerRescale->SetCoef(33.3);
observerRescale->SetStartValue(66.6);
// --------------------- Plug filters and parameters ---------------------------
// From VTK to ITK
vtkToItkFilter->SetInput(img);
// For the filter itself
castFilter->SetInput(vtkToItkFilter->GetOutput());
castFilter->AddObserver( itk::ProgressEvent(), observerCast );
filter->SetInput( castFilter->GetOutput());