-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: MIP image filter for DRR image calculation
The MaximumIntensityForwardProjectionImageFilter is derived from JosephForwardProjectionImageFilter and computes maximum intensity step along the ray casting on the projection.
- Loading branch information
Showing
10 changed files
with
379 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
/*========================================================================= | ||
* | ||
* Copyright RTK Consortium | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0.txt | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*=========================================================================*/ | ||
|
||
#ifndef rtkMaximumIntensityProjectionImageFilter_h | ||
#define rtkMaximumIntensityProjectionImageFilter_h | ||
|
||
#include "rtkJosephForwardProjectionImageFilter.h" | ||
|
||
namespace rtk | ||
{ | ||
namespace Functor | ||
{ | ||
|
||
/** \class MaximumIntensityAlongRay | ||
* \brief Function to compute the maximum intensity (MIP) value along the ray projection. | ||
* | ||
* \author Mikhail Polkovnikov | ||
* | ||
* \ingroup RTK Functions | ||
*/ | ||
template <class TInput, class TOutput> | ||
class ITK_TEMPLATE_EXPORT MaximumIntensityAlongRay | ||
{ | ||
public: | ||
using VectorType = itk::Vector<double, 3>; | ||
|
||
MaximumIntensityAlongRay() = default; | ||
~MaximumIntensityAlongRay() = default; | ||
bool | ||
operator!=(const MaximumIntensityAlongRay &) const | ||
{ | ||
return false; | ||
} | ||
bool | ||
operator==(const MaximumIntensityAlongRay & other) const | ||
{ | ||
return !(*this != other); | ||
} | ||
|
||
inline void | ||
operator()(const ThreadIdType itkNotUsed(threadId), | ||
TOutput & mipValue, | ||
const TInput volumeValue, | ||
const VectorType & itkNotUsed(stepInMM)) | ||
{ | ||
TOutput tmp = static_cast<TOutput>(volumeValue); | ||
if (tmp > mipValue) | ||
{ | ||
mipValue = tmp; | ||
} | ||
} | ||
}; | ||
|
||
/** \class MaximumIntensityProjectedValueAccumulation | ||
* \brief Function to calculate maximum intensity step along the ray projection. | ||
* | ||
* \author Mikhail Polkovnikov | ||
* | ||
* \ingroup RTK Functions | ||
*/ | ||
template <class TInput, class TOutput> | ||
class ITK_TEMPLATE_EXPORT MaximumIntensityProjectedValueAccumulation | ||
{ | ||
public: | ||
using VectorType = itk::Vector<double, 3>; | ||
|
||
bool | ||
operator!=(const MaximumIntensityProjectedValueAccumulation &) const | ||
{ | ||
return false; | ||
} | ||
bool | ||
operator==(const MaximumIntensityProjectedValueAccumulation & other) const | ||
{ | ||
return !(*this != other); | ||
} | ||
|
||
inline void | ||
operator()(const ThreadIdType itkNotUsed(threadId), | ||
const TInput & input, | ||
TOutput & output, | ||
const TOutput & rayCastValue, | ||
const VectorType & stepInMM, | ||
const VectorType & itkNotUsed(source), | ||
const VectorType & itkNotUsed(sourceToPixel), | ||
const VectorType & itkNotUsed(nearestPoint), | ||
const VectorType & itkNotUsed(farthestPoint)) const | ||
{ | ||
TOutput tmp = static_cast<TOutput>(input); | ||
if (tmp < rayCastValue) | ||
{ | ||
tmp = rayCastValue; | ||
} | ||
output = tmp * stepInMM.GetNorm(); | ||
} | ||
}; | ||
|
||
} // end namespace Functor | ||
|
||
|
||
/** \class MaximumIntensityProjectionImageFilter | ||
* \brief MIP filter. | ||
* | ||
* Performs a MIP forward projection, i.e. calculation of a maximum intensity | ||
* step along the x-ray line. | ||
* | ||
* \author Mikhail Polkovnikov | ||
* | ||
* \ingroup RTK Projector | ||
*/ | ||
|
||
template <class TInputImage, | ||
class TOutputImage, | ||
class TInterpolationWeightMultiplication = Functor::InterpolationWeightMultiplication< | ||
typename TInputImage::PixelType, | ||
typename itk::PixelTraits<typename TInputImage::PixelType>::ValueType>, | ||
class TProjectedValueAccumulation = | ||
Functor::MaximumIntensityProjectedValueAccumulation<typename TInputImage::PixelType, | ||
typename TOutputImage::PixelType>, | ||
class TSumAlongRay = | ||
Functor::MaximumIntensityAlongRay<typename TInputImage::PixelType, typename TOutputImage::PixelType>> | ||
class ITK_TEMPLATE_EXPORT MaximumIntensityProjectionImageFilter | ||
: public JosephForwardProjectionImageFilter<TInputImage, | ||
TOutputImage, | ||
TInterpolationWeightMultiplication, | ||
TProjectedValueAccumulation, | ||
TSumAlongRay> | ||
{ | ||
public: | ||
ITK_DISALLOW_COPY_AND_MOVE(MaximumIntensityProjectionImageFilter); | ||
|
||
/** Standard class type alias. */ | ||
using Self = MaximumIntensityProjectionImageFilter; | ||
using Pointer = itk::SmartPointer<Self>; | ||
|
||
/** Method for creation through the object factory. */ | ||
itkNewMacro(Self); | ||
|
||
/** Run-time type information (and related methods). */ | ||
#ifdef itkOverrideGetNameOfClassMacro | ||
itkOverrideGetNameOfClassMacro(MaximumIntensityProjectionImageFilter); | ||
#else | ||
itkTypeMacro(MaximumIntensityProjectionImageFilter, JosephForwardProjectionImageFilter); | ||
#endif | ||
|
||
protected: | ||
MaximumIntensityProjectionImageFilter() = default; | ||
~MaximumIntensityProjectionImageFilter() override = default; | ||
}; | ||
} // end namespace rtk | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env python | ||
from __future__ import print_function | ||
import itk | ||
from itk import RTK as rtk | ||
import sys | ||
import os | ||
|
||
TImageType = itk.Image[itk.F,3] | ||
# Defines the RTK geometry object | ||
geometry = rtk.ThreeDCircularProjectionGeometry.New() | ||
numberOfProjections = 1 | ||
geometry.AddProjection(700, 800, 0) | ||
# Constant image sources | ||
# Create MIP Forward Projector volume | ||
volInput = rtk.ConstantImageSource[TImageType].New() | ||
origin = [ 0., 0., 0. ] | ||
size = [ 64, 64, 64 ] | ||
sizeOutput = [ 200, 200, numberOfProjections ] | ||
spacing = [ 4.0, 4.0, 4.0 ] | ||
spacingOutput = [ 1.0, 1.0, 1.0 ] | ||
volInput.SetOrigin( origin ) | ||
volInput.SetSpacing( spacing ) | ||
volInput.SetSize( size ) | ||
volInput.SetConstant(1.0) | ||
volInput.UpdateOutputInformation() | ||
volInputSource = volInput.GetOutput() | ||
# Initialization Imager volume | ||
projInput = rtk.ConstantImageSource[TImageType].New() | ||
projInput.SetOrigin( origin ) | ||
projInput.SetSpacing( spacingOutput ) | ||
projInput.SetSize( sizeOutput ) | ||
projInput.SetConstant(0.) | ||
projInput.Update() | ||
projInputSource = projInput.GetOutput() | ||
# MIP Forward Projection filter | ||
mip = rtk.MaximumIntensityProjectionImageFilter[TImageType, TImageType].New() | ||
mip.SetGeometry( geometry ) | ||
mip.SetInput(volInputSource) | ||
mip.SetInput(1, projInputSource) | ||
mipImage = mip.GetOutput() |
Oops, something went wrong.