VMTK
Loading...
Searching...
No Matches
vtkvmtkImageBoxPainter Class Reference

Create a box shaped sub-volume within a 3D image and paint (assign a value to) every sub-volume element with the same value. More...

#include <vtkvmtkImageBoxPainter.h>

Inheritance diagram for vtkvmtkImageBoxPainter:
[legend]
Collaboration diagram for vtkvmtkImageBoxPainter:
[legend]

Public Types

typedef vtkSimpleImageToImageFilter Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkImageBoxPainter * NewInstance () const
void SetBoxDefinitionToUseExtent ()
void SetBoxDefinitionToUseBounds ()
virtual double GetPaintValue ()
virtual void SetPaintValue (double)
virtual double * GetBoxBounds ()
virtual void GetBoxBounds (double data[6])
virtual void SetBoxBounds (double data[])
virtual int * GetBoxExtent ()
virtual void GetBoxExtent (int data[6])
virtual void SetBoxExtent (int data[])
virtual int GetBoxDefinition ()
virtual void SetBoxDefinition (int)

Static Public Member Functions

static vtkvmtkImageBoxPainter * New ()
static int IsTypeOf (const char *type)
static vtkvmtkImageBoxPainter * SafeDownCast (vtkObjectBase *o)

Protected Types

enum  { USE_BOUNDS , USE_EXTENT }

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkImageBoxPainter ()
 ~vtkvmtkImageBoxPainter ()
virtual void SimpleExecute (vtkImageData *input, vtkImageData *output) override

Protected Attributes

double PaintValue
double BoxBounds [6]
int BoxExtent [6]
int BoxDefinition

Detailed Description

Create a box shaped sub-volume within a 3D image and paint (assign a value to) every sub-volume element with the same value.

This filter copies the input image and overwrites every voxel inside an axis-aligned box sub-region with PaintValue, leaving voxels outside the box unchanged. The box can be specified either as a voxel index range (BoxExtent) or as physical bounds (BoxBounds, converted to the nearest enclosed extent using the image spacing); which one is used is selected with BoxDefinition / SetBoxDefinitionToUseExtent / SetBoxDefinitionToUseBounds.

This is the filter behind the vmtkimagevoipainter pype script, typically used to blank out or flag a rectangular region of interest in an image (e.g. to mask out part of a scan before further processing).

Definition at line 39 of file vtkvmtkImageBoxPainter.h.

Member Typedef Documentation

◆ Superclass

typedef vtkSimpleImageToImageFilter vtkvmtkImageBoxPainter::Superclass

Definition at line 43 of file vtkvmtkImageBoxPainter.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
USE_BOUNDS 
USE_EXTENT 

Definition at line 109 of file vtkvmtkImageBoxPainter.h.

Constructor & Destructor Documentation

◆ vtkvmtkImageBoxPainter()

vtkvmtkImageBoxPainter::vtkvmtkImageBoxPainter ( )
protected

Definition at line 32 of file vtkvmtkImageBoxPainter.cxx.

33{
34 this->PaintValue = 0.0;
35
36 this->BoxBounds[0] = this->BoxBounds[2] = this->BoxBounds[4] = 0.0;
37 this->BoxBounds[1] = this->BoxBounds[3] = this->BoxBounds[5] = 1.0;
38
39 this->BoxExtent[0] = this->BoxExtent[2] = this->BoxExtent[4] = 0;
40 this->BoxExtent[1] = this->BoxExtent[3] = this->BoxExtent[5] = 1;
41
43}

◆ ~vtkvmtkImageBoxPainter()

vtkvmtkImageBoxPainter::~vtkvmtkImageBoxPainter ( )
inlineprotected

Definition at line 99 of file vtkvmtkImageBoxPainter.h.

99{};

Member Function Documentation

◆ New()

vtkvmtkImageBoxPainter * vtkvmtkImageBoxPainter::New ( )
static

◆ IsTypeOf()

int vtkvmtkImageBoxPainter::IsTypeOf ( const char * type)
static

◆ IsA()

virtual int vtkvmtkImageBoxPainter::IsA ( const char * type)
virtual

◆ SafeDownCast()

vtkvmtkImageBoxPainter * vtkvmtkImageBoxPainter::SafeDownCast ( vtkObjectBase * o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkImageBoxPainter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkImageBoxPainter * vtkvmtkImageBoxPainter::NewInstance ( ) const

◆ GetPaintValue()

virtual double vtkvmtkImageBoxPainter::GetPaintValue ( )
virtual

Set/Get the scalar value assigned to every voxel inside the box region. Default: 0.0.

◆ SetPaintValue()

virtual void vtkvmtkImageBoxPainter::SetPaintValue ( double )
virtual

Set/Get the scalar value assigned to every voxel inside the box region. Default: 0.0.

◆ GetBoxBounds() [1/2]

virtual double * vtkvmtkImageBoxPainter::GetBoxBounds ( )
virtual

Set/Get the box region in physical (world) coordinates, as (xmin,xmax,ymin,ymax,zmin,zmax). Only used when BoxDefinition is USE_BOUNDS (see SetBoxDefinitionToUseBounds); converted internally to the nearest enclosed voxel extent using the input image spacing.

◆ GetBoxBounds() [2/2]

virtual void vtkvmtkImageBoxPainter::GetBoxBounds ( double data[6])
virtual

Set/Get the box region in physical (world) coordinates, as (xmin,xmax,ymin,ymax,zmin,zmax). Only used when BoxDefinition is USE_BOUNDS (see SetBoxDefinitionToUseBounds); converted internally to the nearest enclosed voxel extent using the input image spacing.

◆ SetBoxBounds()

virtual void vtkvmtkImageBoxPainter::SetBoxBounds ( double data[])
virtual

Set/Get the box region in physical (world) coordinates, as (xmin,xmax,ymin,ymax,zmin,zmax). Only used when BoxDefinition is USE_BOUNDS (see SetBoxDefinitionToUseBounds); converted internally to the nearest enclosed voxel extent using the input image spacing.

◆ GetBoxExtent() [1/2]

virtual int * vtkvmtkImageBoxPainter::GetBoxExtent ( )
virtual

Set/Get the box region in voxel index coordinates, as (imin,imax,jmin,jmax,kmin,kmax). Used directly when BoxDefinition is USE_EXTENT (see SetBoxDefinitionToUseExtent, the default); also holds the result of converting BoxBounds when BoxDefinition is USE_BOUNDS.

◆ GetBoxExtent() [2/2]

virtual void vtkvmtkImageBoxPainter::GetBoxExtent ( int data[6])
virtual

Set/Get the box region in voxel index coordinates, as (imin,imax,jmin,jmax,kmin,kmax). Used directly when BoxDefinition is USE_EXTENT (see SetBoxDefinitionToUseExtent, the default); also holds the result of converting BoxBounds when BoxDefinition is USE_BOUNDS.

◆ SetBoxExtent()

virtual void vtkvmtkImageBoxPainter::SetBoxExtent ( int data[])
virtual

Set/Get the box region in voxel index coordinates, as (imin,imax,jmin,jmax,kmin,kmax). Used directly when BoxDefinition is USE_EXTENT (see SetBoxDefinitionToUseExtent, the default); also holds the result of converting BoxBounds when BoxDefinition is USE_BOUNDS.

◆ GetBoxDefinition()

virtual int vtkvmtkImageBoxPainter::GetBoxDefinition ( )
virtual

Set/Get whether the painted box region is specified through BoxExtent (USE_EXTENT, the default) or through BoxBounds (USE_BOUNDS). Prefer the SetBoxDefinitionToUseExtent / SetBoxDefinitionToUseBounds convenience methods over setting this enum value directly.

◆ SetBoxDefinition()

virtual void vtkvmtkImageBoxPainter::SetBoxDefinition ( int )
virtual

Set/Get whether the painted box region is specified through BoxExtent (USE_EXTENT, the default) or through BoxBounds (USE_BOUNDS). Prefer the SetBoxDefinitionToUseExtent / SetBoxDefinitionToUseBounds convenience methods over setting this enum value directly.

◆ SetBoxDefinitionToUseExtent()

void vtkvmtkImageBoxPainter::SetBoxDefinitionToUseExtent ( )
inline

Specify the painted box region through BoxExtent (voxel index range). See BoxDefinition.

Definition at line 87 of file vtkvmtkImageBoxPainter.h.

◆ SetBoxDefinitionToUseBounds()

void vtkvmtkImageBoxPainter::SetBoxDefinitionToUseBounds ( )
inline

Specify the painted box region through BoxBounds (physical coordinate range). See BoxDefinition.

Definition at line 93 of file vtkvmtkImageBoxPainter.h.

◆ SimpleExecute()

void vtkvmtkImageBoxPainter::SimpleExecute ( vtkImageData * input,
vtkImageData * output )
overrideprotectedvirtual

Definition at line 87 of file vtkvmtkImageBoxPainter.cxx.

89{
90
91 void* inPtr = input->GetScalarPointer();
92 void* outPtr = output->GetScalarPointer();
93
94 double spacing[3];
95 input->GetSpacing(spacing);
96
98 {
99 this->BoxExtent[0] = (vtkIdType) std::ceil(this->BoxBounds[0] / spacing[0]);
100 this->BoxExtent[1] = (vtkIdType) std::floor(this->BoxBounds[1] / spacing[0]);
101 this->BoxExtent[2] = (vtkIdType) std::ceil(this->BoxBounds[2] / spacing[1]);
102 this->BoxExtent[3] = (vtkIdType) std::floor(this->BoxBounds[3] / spacing[1]);
103 this->BoxExtent[4] = (vtkIdType) std::ceil(this->BoxBounds[4] / spacing[2]);
104 this->BoxExtent[5] = (vtkIdType) std::floor(this->BoxBounds[5] / spacing[2]);
105 }
106
107 int extent[6];
108 vtkInformation *inInfoImage = this->GetInputPortInformation(0);
109 inInfoImage->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), extent);
110
111 if ( this->BoxExtent[0] < extent[0] || this->BoxExtent[1] > extent[1] ||
112 this->BoxExtent[2] < extent[2] || this->BoxExtent[3] > extent[3] ||
113 this->BoxExtent[4] < extent[4] || this->BoxExtent[5] > extent[5] )
114 {
115 vtkErrorMacro(<<"BoxExtent exceeds input WholeExtent");
116 return;
117 }
118
119 int relativeBoxExtent[6];
120 relativeBoxExtent[0] = this->BoxExtent[0] - extent[0];
121 relativeBoxExtent[1] = this->BoxExtent[1] - extent[0];
122 relativeBoxExtent[2] = this->BoxExtent[2] - extent[2];
123 relativeBoxExtent[3] = this->BoxExtent[3] - extent[2];
124 relativeBoxExtent[4] = this->BoxExtent[4] - extent[4];
125 relativeBoxExtent[5] = this->BoxExtent[5] - extent[4];
126
127 switch(output->GetScalarType())
128 {
129 // This is simple a #define for a big case list. It handles
130 // all data types vtk can handle.
131 vtkTemplateMacro(vtkvmtkImageBoxPainterExecute( input, output,
132 static_cast<VTK_TT *>(inPtr), static_cast<VTK_TT *>(outPtr), relativeBoxExtent,
133 static_cast<VTK_TT>(this->PaintValue)));
134 default:
135 vtkGenericWarningMacro("Execute: Unknown input ScalarType");
136 return;
137 }
138}
void vtkvmtkImageBoxPainterExecute(vtkImageData *input, vtkImageData *output, IT *inPtr, IT *outPtr, int *boxExtent, IT paintValue)

Member Data Documentation

◆ PaintValue

double vtkvmtkImageBoxPainter::PaintValue
protected

Definition at line 103 of file vtkvmtkImageBoxPainter.h.

◆ BoxBounds

double vtkvmtkImageBoxPainter::BoxBounds[6]
protected

Definition at line 104 of file vtkvmtkImageBoxPainter.h.

◆ BoxExtent

int vtkvmtkImageBoxPainter::BoxExtent[6]
protected

Definition at line 105 of file vtkvmtkImageBoxPainter.h.

◆ BoxDefinition

int vtkvmtkImageBoxPainter::BoxDefinition
protected

Definition at line 107 of file vtkvmtkImageBoxPainter.h.


The documentation for this class was generated from the following files: