19 #include <vtkPolyLine.h>
20 #include <vtkCellArray.h>
21 #include <vtkCellData.h>
28 template<
class ReferenceImageType,
class OutputImageType >
35 template<
class ReferenceImageType,
class OutputImageType >
40 template<
class ReferenceImageType,
class OutputImageType >
47 static_cast< OutputImageType *
>(this->ProcessObject::GetPrimaryOutput());
49 typename InputImageType::RegionType region = rgbaImage->GetLargestPossibleRegion();
50 outputImage->SetSpacing( m_ReferenceImage->GetSpacing() );
51 outputImage->SetOrigin( m_ReferenceImage->GetOrigin() );
52 outputImage->SetDirection( m_ReferenceImage->GetDirection() );
53 outputImage->SetRegions( m_ReferenceImage->GetLargestPossibleRegion());
54 outputImage->Allocate();
55 outputImage->FillBuffer(0);
56 float* outImageBufferPointer = outputImage->GetBufferPointer();
59 counterImage->SetSpacing( m_ReferenceImage->GetSpacing() );
60 counterImage->SetOrigin( m_ReferenceImage->GetOrigin() );
61 counterImage->SetDirection( m_ReferenceImage->GetDirection() );
62 counterImage->SetRegions( m_ReferenceImage->GetLargestPossibleRegion());
63 counterImage->Allocate();
64 counterImage->FillBuffer(0);
65 short* counterImageBufferPointer = counterImage->GetBufferPointer();
67 int w = m_ReferenceImage->GetLargestPossibleRegion().GetSize().GetElement(0);
68 int h = m_ReferenceImage->GetLargestPossibleRegion().GetSize().GetElement(1);
69 int d = m_ReferenceImage->GetLargestPossibleRegion().GetSize().GetElement(2);
71 typedef ImageRegionConstIterator< InputImageType > InImageIteratorType;
72 InImageIteratorType rgbaIt(rgbaImage, region);
74 while(!rgbaIt.IsAtEnd()){
79 itk::Point<float, 3> vertex;
82 rgbaImage->TransformIndexToPhysicalPoint(index, vertex);
83 outputImage->TransformPhysicalPointToIndex(vertex, index);
85 itk::ContinuousIndex<float, 3> contIndex;
86 outputImage->TransformPhysicalPointToContinuousIndex(vertex, contIndex);
88 float frac_x = contIndex[0] - index[0];
89 float frac_y = contIndex[1] - index[1];
90 float frac_z = contIndex[2] - index[2];
114 if (px < 0 || px >= w-1)
116 if (py < 0 || py >= h-1)
118 if (pz < 0 || pz >= d-1)
125 out = (float)x.GetRed()/255;
128 out = (float)x.GetGreen()/255;
131 out = (float)x.GetBlue()/255;
134 out = (float)x.GetAlpha()/255;
137 outImageBufferPointer[( px + w*(py + h*pz ))] += out*( frac_x)*( frac_y)*( frac_z);
138 outImageBufferPointer[( px + w*(py+1+ h*pz ))] += out*( frac_x)*(1-frac_y)*( frac_z);
139 outImageBufferPointer[( px + w*(py + h*pz+h))] += out*( frac_x)*( frac_y)*(1-frac_z);
140 outImageBufferPointer[( px + w*(py+1+ h*pz+h))] += out*( frac_x)*(1-frac_y)*(1-frac_z);
141 outImageBufferPointer[( px+1 + w*(py + h*pz ))] += out*(1-frac_x)*( frac_y)*( frac_z);
142 outImageBufferPointer[( px+1 + w*(py + h*pz+h))] += out*(1-frac_x)*( frac_y)*(1-frac_z);
143 outImageBufferPointer[( px+1 + w*(py+1+ h*pz ))] += out*(1-frac_x)*(1-frac_y)*( frac_z);
144 outImageBufferPointer[( px+1 + w*(py+1+ h*pz+h))] += out*(1-frac_x)*(1-frac_y)*(1-frac_z);
146 counterImageBufferPointer[( px + w*(py + h*pz ))] += 1;
147 counterImageBufferPointer[( px + w*(py+1+ h*pz ))] += 1;
148 counterImageBufferPointer[( px + w*(py + h*pz+h))] += 1;
149 counterImageBufferPointer[( px + w*(py+1+ h*pz+h))] += 1;
150 counterImageBufferPointer[( px+1 + w*(py + h*pz ))] += 1;
151 counterImageBufferPointer[( px+1 + w*(py + h*pz+h))] += 1;
152 counterImageBufferPointer[( px+1 + w*(py+1+ h*pz ))] += 1;
153 counterImageBufferPointer[( px+1 + w*(py+1+ h*pz+h))] += 1;
157 typedef ImageRegionIterator< OutputImageType > OutImageIteratorType;
158 OutImageIteratorType outIt(outputImage, outputImage->GetLargestPossibleRegion());
160 typedef ImageRegionConstIterator< itk::Image< short, 3 > > CountImageIteratorType;
161 CountImageIteratorType counterIt(counterImage, counterImage->GetLargestPossibleRegion());
162 counterIt.GoToBegin();
164 while(!outIt.IsAtEnd() && !counterIt.IsAtEnd()){
165 if (counterIt.Value()>0)
166 outIt.Set(outIt.Value()/counterIt.Value());
itk::SmartPointer< Self > Pointer
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.