-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.cxx
57 lines (47 loc) · 1.94 KB
/
utils.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* \file: utils.cxx
* \author: Sankhesh Jhaveri
* \brief: defines UTILS namespace functions
**/
#include "utils.h"
#include <itkComposeRGBImageFilter.h>
#include <itkRescaleIntensityImageFilter.h>
namespace UTILS {
void redirectVTKWarnings( const vcl_string &fname )
{
vtkFileOutputWindow *outwin = vtkFileOutputWindow::New();
outwin->SetFileName( fname.c_str() );
outwin->SetGlobalWarningDisplay( 0 );
outwin->SetInstance( outwin );
}
vtkSmartPointer<vtkImageActor> ITKToVTKConvert( RGBImageType::Pointer IP )
{
//typedef itk::ImageToVTKImageFilter<IMPROC::baseFilter::RGBImageType> itkImageTovtkImageFilterType;
typedef itk::ImageToVTKImageFilter<RGBImageType> itkImageTovtkImageFilterType;
itkImageTovtkImageFilterType::Pointer ImageTovtkImageFilter = itkImageTovtkImageFilterType::New();
ImageTovtkImageFilter->SetInput( IP );
//ImageTovtkImageFilter->Update();
vtkSmartPointer<vtkImageFlip> flipY = vtkSmartPointer<vtkImageFlip>::New();
flipY->SetInput( ImageTovtkImageFilter->GetOutput() );
flipY->SetFilteredAxis(1);
flipY->Update();
vtkSmartPointer<vtkImageActor> actor = vtkSmartPointer<vtkImageActor>::New();
actor->SetInput( flipY->GetOutput() );
return actor;
}
RGBImageType::Pointer ComposeRGBImage( ScalarImageType::Pointer scalarImage )
{
typedef itk::RescaleIntensityImageFilter<ScalarImageType,ScalarImageType> RescaleFilterType;
RescaleFilterType::Pointer rescalefilter = RescaleFilterType::New();
rescalefilter->SetInput( scalarImage );
rescalefilter->SetOutputMinimum(0);
rescalefilter->SetOutputMaximum(255);
typedef itk::ComposeRGBImageFilter< ScalarImageType, RGBImageType > composefilterType;
composefilterType::Pointer composeFilter = composefilterType::New();
composeFilter->SetInput1( rescalefilter->GetOutput() );
composeFilter->SetInput2( rescalefilter->GetOutput() );
composeFilter->SetInput3( rescalefilter->GetOutput() );
composeFilter->Update();
return composeFilter->GetOutput();
}
} //namespace UTILS