forked from BlueQuartzSoftware/ITKImageProcessing
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ProxTVImage filter (BlueQuartzSoftware#182)
* Git on Linux really want this file to have LF line endings * Updating the filter creation script to parse with Python 3 This update just avoids syntax errors on reading the script. Trying to run this script using Python 3 causes an exception. * ENH: generate ProxTVImage filter, add it to source and test lists
- Loading branch information
1 parent
9ba8ac6
commit 435d1fc
Showing
10 changed files
with
2,899 additions
and
2,484 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
ITK::Prox T V Image Filter (KW) {#itkproxtvimage} | ||
============== | ||
|
||
## Group (Subgroup) ## | ||
|
||
ITKImageProcessing (ITKImageProcessing) | ||
|
||
## Description ## | ||
|
||
Applies a total variation noise reduction filter to an image. | ||
|
||
ProxTVImageFilter from https://github.com/InsightSoftwareConsortium/ITKTotalVariation | ||
|
||
## Parameters ## | ||
|
||
| Name | Type | Description | | ||
|------|------|-------------| | ||
| MaximumNumberOfIterations | double| Get and set the maximum number of iterations. | | ||
| Weights | FloatVec3Type| N/A | | ||
| Norms | FloatVec3Type| N/A | | ||
|
||
|
||
## Required Geometry ## | ||
|
||
Image | ||
|
||
## Required Objects ## | ||
|
||
| Kind | Default Name | Type | Component Dimensions | Description | | ||
|------|--------------|------|----------------------|-------------| | ||
| **Cell Attribute Array** | None | N/A | (1) | Array containing input image | ||
|
||
## Created Objects ## | ||
|
||
| Kind | Default Name | Type | Component Dimensions | Description | | ||
|------|--------------|------|----------------------|-------------| | ||
| **Cell Attribute Array** | None | | (1) | Array containing filtered image | ||
|
||
## References ## | ||
|
||
[1] T.S. Yoo, M. J. Ackerman, W. E. Lorensen, W. Schroeder, V. Chalana, S. Aylward, D. Metaxas, R. Whitaker. Engineering and Algorithm Design for an Image Processing API: A Technical Report on ITK - The Insight Toolkit. In Proc. of Medicine Meets Virtual Reality, J. Westwood, ed., IOS Press Amsterdam pp 586-592 (2002). | ||
[2] H. Johnson, M. McCormick, L. Ibanez. The ITK Software Guide: Design and Functionality. Fourth Edition. Published by Kitware Inc. 2015 ISBN: 9781-930934-28-3 | ||
[3] H. Johnson, M. McCormick, L. Ibanez. The ITK Software Guide: Introduction and Development Guidelines. Fourth Edition. Published by Kitware Inc. 2015 ISBN: 9781-930934-27-6 | ||
|
||
## Example Pipelines ## | ||
|
||
|
||
|
||
## License & Copyright ## | ||
|
||
Please see the description file distributed with this plugin. | ||
|
||
## DREAM3D Mailing Lists ## | ||
|
||
If you need more help with a filter, please consider asking your question on the DREAM3D Users mailing list: | ||
https://groups.google.com/forum/?hl=en#!forum/dream3d-users |
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 @@ | ||
// File automatically generated | ||
|
||
/* | ||
* Your License or Copyright can go here | ||
*/ | ||
|
||
#include "ITKImageProcessing/ITKImageProcessingFilters/ITKProxTVImage.h" | ||
#include "SIMPLib/ITK/SimpleITKEnums.h" | ||
|
||
#include "SIMPLib/Common/Constants.h" | ||
#include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" | ||
#include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" | ||
#include "SIMPLib/FilterParameters/LinkedBooleanFilterParameter.h" | ||
#include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" | ||
#include "SIMPLib/FilterParameters/StringFilterParameter.h" | ||
|
||
#include "SIMPLib/Geometry/ImageGeom.h" | ||
|
||
#include "SIMPLib/ITK/Dream3DTemplateAliasMacro.h" | ||
#include "SIMPLib/ITK/itkDream3DImage.h" | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
ITKProxTVImage::ITKProxTVImage() | ||
{ | ||
m_MaximumNumberOfIterations = StaticCastScalar<double, double, double>(10u); | ||
m_Weights = CastStdToVec3<std::vector<double>, FloatVec3Type, float>(std::vector<double>(3, 1.0)); | ||
m_Norms = CastStdToVec3<std::vector<double>, FloatVec3Type, float>(std::vector<double>(3, 1.0)); | ||
|
||
setupFilterParameters(); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
ITKProxTVImage::~ITKProxTVImage() = default; | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void ITKProxTVImage::setupFilterParameters() | ||
{ | ||
FilterParameterVectorType parameters; | ||
|
||
parameters.push_back(SIMPL_NEW_DOUBLE_FP("MaximumNumberOfIterations", MaximumNumberOfIterations, FilterParameter::Parameter, ITKProxTVImage)); | ||
parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Weights", Weights, FilterParameter::Parameter, ITKProxTVImage)); | ||
parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Norms", Norms, FilterParameter::Parameter, ITKProxTVImage)); | ||
|
||
|
||
QStringList linkedProps; | ||
linkedProps << "NewCellArrayName"; | ||
parameters.push_back(SIMPL_NEW_LINKED_BOOL_FP("Save as New Array", SaveAsNewArray, FilterParameter::Parameter, ITKProxTVImage, linkedProps)); | ||
parameters.push_back(SeparatorFilterParameter::New("Cell Data", FilterParameter::RequiredArray)); | ||
{ | ||
DataArraySelectionFilterParameter::RequirementType req = | ||
DataArraySelectionFilterParameter::CreateRequirement(SIMPL::Defaults::AnyPrimitive, SIMPL::Defaults::AnyComponentSize, AttributeMatrix::Type::Cell, IGeometry::Type::Image); | ||
parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Attribute Array to filter", SelectedCellArrayPath, FilterParameter::RequiredArray, ITKProxTVImage, req)); | ||
} | ||
parameters.push_back(SeparatorFilterParameter::New("Cell Data", FilterParameter::CreatedArray)); | ||
parameters.push_back(SIMPL_NEW_STRING_FP("Filtered Array", NewCellArrayName, FilterParameter::CreatedArray, ITKProxTVImage)); | ||
|
||
setFilterParameters(parameters); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void ITKProxTVImage::readFilterParameters(AbstractFilterParametersReader* reader, int index) | ||
{ | ||
reader->openFilterGroup(this, index); | ||
setSelectedCellArrayPath(reader->readDataArrayPath("SelectedCellArrayPath", getSelectedCellArrayPath())); | ||
setNewCellArrayName(reader->readString("NewCellArrayName", getNewCellArrayName())); | ||
setSaveAsNewArray(reader->readValue("SaveAsNewArray", getSaveAsNewArray())); | ||
setMaximumNumberOfIterations(reader->readValue("MaximumNumberOfIterations", getMaximumNumberOfIterations())); | ||
setWeights(reader->readFloatVec3("Weights", getWeights())); | ||
setNorms(reader->readFloatVec3("Norms", getNorms())); | ||
|
||
reader->closeFilterGroup(); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
template <typename InputPixelType, typename OutputPixelType, unsigned int Dimension> void ITKProxTVImage::dataCheck() | ||
{ | ||
clearErrorCode(); | ||
clearWarningCode(); | ||
|
||
// Check consistency of parameters | ||
this->CheckIntegerEntry<unsigned int, double>(m_MaximumNumberOfIterations, "MaximumNumberOfIterations", 1); | ||
this->CheckVectorEntry<double, FloatVec3Type>(m_Weights, "Weights", 0); | ||
this->CheckVectorEntry<double, FloatVec3Type>(m_Norms, "Norms", 0); | ||
|
||
ITKImageProcessingBase::dataCheck<InputPixelType, OutputPixelType, Dimension>(); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void ITKProxTVImage::dataCheckInternal() | ||
{ | ||
Dream3DArraySwitchMacro(this->dataCheck, getSelectedCellArrayPath(), -4); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
|
||
template <typename InputPixelType, typename OutputPixelType, unsigned int Dimension> void ITKProxTVImage::filter() | ||
{ | ||
typedef itk::Dream3DImage<InputPixelType, Dimension> InputImageType; | ||
typedef itk::Dream3DImage<OutputPixelType, Dimension> OutputImageType; | ||
// define filter | ||
typedef itk::ProxTVImageFilter<InputImageType, OutputImageType> FilterType; | ||
typename FilterType::Pointer filter = FilterType::New(); | ||
filter->SetMaximumNumberOfIterations(static_cast<unsigned int>(m_MaximumNumberOfIterations)); | ||
filter->SetWeights(CastVec3ToITK<FloatVec3Type, typename FilterType::ArrayType, typename FilterType::ArrayType::ValueType>(m_Weights, FilterType::ArrayType::Dimension)); | ||
filter->SetNorms(CastVec3ToITK<FloatVec3Type, typename FilterType::ArrayType, typename FilterType::ArrayType::ValueType>(m_Norms, FilterType::ArrayType::Dimension)); | ||
this->ITKImageProcessingBase::filter<InputPixelType, OutputPixelType, Dimension, FilterType>(filter); | ||
|
||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void ITKProxTVImage::filterInternal() | ||
{ | ||
Dream3DArraySwitchMacro(this->filter, getSelectedCellArrayPath(), -4); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
AbstractFilter::Pointer ITKProxTVImage::newFilterInstance(bool copyFilterParameters) const | ||
{ | ||
ITKProxTVImage::Pointer filter = ITKProxTVImage::New(); | ||
if(copyFilterParameters) | ||
{ | ||
copyFilterParameterInstanceVariables(filter.get()); | ||
} | ||
return filter; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
const QString ITKProxTVImage::getHumanLabel() const | ||
{ | ||
return "ITK::Prox T V Image Filter"; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
const QUuid ITKProxTVImage::getUuid() | ||
{ | ||
return QUuid("{d3856d4c-5651-5eab-8740-489a87fa8bdd}"); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
const QString ITKProxTVImage::getSubGroupName() const | ||
{ | ||
return "ITK NoModule"; | ||
} |
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,111 @@ | ||
// File automatically generated | ||
|
||
/* | ||
* Your License or Copyright can go here | ||
*/ | ||
#pragma once | ||
|
||
|
||
#ifdef __clang__ | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Winconsistent-missing-override" | ||
#endif | ||
|
||
#include "ITKImageProcessingBase.h" | ||
|
||
#include "SIMPLib/Common/SIMPLibSetGetMacros.h" | ||
#include "SIMPLib/SIMPLib.h" | ||
|
||
// Auto includes | ||
#include <SIMPLib/FilterParameters/DoubleFilterParameter.h> | ||
#include <SIMPLib/FilterParameters/FloatVec3FilterParameter.h> | ||
#include <itkProxTVImageFilter.h> | ||
|
||
|
||
/** | ||
* @brief The ITKProxTVImage class. See [Filter documentation](@ref ITKProxTVImage) for details. | ||
*/ | ||
class ITKProxTVImage : public ITKImageProcessingBase | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
SIMPL_SHARED_POINTERS(ITKProxTVImage) | ||
SIMPL_FILTER_NEW_MACRO(ITKProxTVImage) | ||
SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ITKProxTVImage, AbstractFilter) | ||
|
||
~ITKProxTVImage() override; | ||
|
||
SIMPL_FILTER_PARAMETER(double, MaximumNumberOfIterations) | ||
Q_PROPERTY(double MaximumNumberOfIterations READ getMaximumNumberOfIterations WRITE setMaximumNumberOfIterations) | ||
|
||
SIMPL_FILTER_PARAMETER(FloatVec3Type, Weights) | ||
Q_PROPERTY(FloatVec3Type Weights READ getWeights WRITE setWeights) | ||
|
||
SIMPL_FILTER_PARAMETER(FloatVec3Type, Norms) | ||
Q_PROPERTY(FloatVec3Type Norms READ getNorms WRITE setNorms) | ||
|
||
|
||
/** | ||
* @brief newFilterInstance Reimplemented from @see AbstractFilter class | ||
*/ | ||
AbstractFilter::Pointer | ||
newFilterInstance(bool copyFilterParameters) const override; | ||
|
||
/** | ||
* @brief getHumanLabel Reimplemented from @see AbstractFilter class | ||
*/ | ||
const QString getHumanLabel() const override; | ||
|
||
/** | ||
* @brief getSubGroupName Reimplemented from @see AbstractFilter class | ||
*/ | ||
const QString getSubGroupName() const override; | ||
|
||
/** | ||
* @brief getUuid Return the unique identifier for this filter. | ||
* @return A QUuid object. | ||
*/ | ||
const QUuid getUuid() override; | ||
|
||
/** | ||
* @brief setupFilterParameters Reimplemented from @see AbstractFilter class | ||
*/ | ||
void setupFilterParameters() override; | ||
|
||
/** | ||
* @brief readFilterParameters Reimplemented from @see AbstractFilter class | ||
*/ | ||
void readFilterParameters(AbstractFilterParametersReader * reader, int index) override; | ||
|
||
protected: | ||
ITKProxTVImage(); | ||
|
||
/** | ||
* @brief dataCheckInternal overloads dataCheckInternal in ITKImageBase and calls templated dataCheck | ||
*/ | ||
void dataCheckInternal() override; | ||
|
||
/** | ||
* @brief dataCheck Checks for the appropriate parameter values and availability of arrays | ||
*/ | ||
template <typename InputImageType, typename OutputImageType, unsigned int Dimension> void dataCheck(); | ||
|
||
/** | ||
* @brief filterInternal overloads filterInternal in ITKImageBase and calls templated filter | ||
*/ | ||
void filterInternal() override; | ||
|
||
/** | ||
* @brief Applies the filter | ||
*/ | ||
template <typename InputImageType, typename OutputImageType, unsigned int Dimension> void filter(); | ||
|
||
private: | ||
ITKProxTVImage(const ITKProxTVImage&) = delete; // Copy Constructor Not Implemented | ||
void operator=(const ITKProxTVImage&) = delete; // Move assignment Not Implemented | ||
}; | ||
|
||
#ifdef __clang__ | ||
#pragma clang diagnostic pop | ||
#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
Oops, something went wrong.