]> Creatis software - creaRigidRegistration.git/blob - lib/Convolution.cxx
\ No newline at end of file
[creaRigidRegistration.git] / lib / Convolution.cxx
1 #include "Convolution.h"
2
3 /*
4 * Constructor
5 */
6 //------------------------------------------------------------
7 Convolution::Convolution()
8 {
9         _image=NULL;
10         _convolve = vtkImageConvolve::New();
11         _cast = vtkImageCast::New();
12 }
13
14 /*
15 * Destructor
16 */
17 //------------------------------------------------------------
18 Convolution::~Convolution()
19 {
20         if (_convolve != NULL ) { _convolve->Delete(); }
21         if (_cast != NULL ) { _cast->Delete(); }
22 }
23
24 vtkImageData *Convolution::getImage()
25 {
26         return _cast->GetOutput();
27 }
28
29 void Convolution::setImage(vtkImageData *image)
30 {
31         _image = image;
32         _convolve->SetInput(_image);
33 }
34
35 void Convolution::setFactor(double factor)
36 {
37         _factor = (factor/100.0)*5.0;   
38 }
39
40 void Convolution::Run()
41 {
42         double kernel[] = {0.0,1.0,0.0,1.0,-_factor,1.0,0.0,1.0,0.0};
43         _convolve->SetKernel3x3(kernel);
44         _convolve->Update();
45         _cast->SetInput(_convolve->GetOutput());
46         _cast->SetOutputScalarTypeToDouble();
47 }
48