2020-01-30 00:51:18 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
|
|
|
//
|
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#ifndef vtk_m_filter_ImageDifference_h
|
|
|
|
#define vtk_m_filter_ImageDifference_h
|
|
|
|
|
|
|
|
#include <vtkm/TypeList.h>
|
|
|
|
#include <vtkm/filter/FilterField.h>
|
|
|
|
|
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
|
|
|
|
|
|
|
/// \brief Construct an ImageDifference of a given DataSet
|
|
|
|
///
|
|
|
|
/// The dataset generated by executing this filter is a Dataset with two Fields:
|
|
|
|
/// - "image-diff": Uniform Structured Dataset, difference values of image A - B
|
|
|
|
/// - "threshold-output": Uniform Structured Dataset, the magnitudes of the pixel differences
|
|
|
|
///
|
|
|
|
/// The threshold-output is calculated for each pixel using the `vtkm::Magnitude` vector function
|
|
|
|
/// on the individual pixel difference.
|
|
|
|
///
|
|
|
|
class ImageDifference : public vtkm::filter::FilterField<ImageDifference>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using SupportedTypes = vtkm::TypeListFieldVec4;
|
|
|
|
|
|
|
|
VTKM_CONT ImageDifference();
|
|
|
|
|
2021-01-05 20:09:01 +00:00
|
|
|
VTKM_CONT vtkm::IdComponent GetAverageRadius() const { return this->AverageRadius; }
|
|
|
|
VTKM_CONT void SetAverageRadius(const vtkm::IdComponent& averageRadius)
|
|
|
|
{
|
|
|
|
this->AverageRadius = averageRadius;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT vtkm::IdComponent GetPixelShiftRadius() const { return this->PixelShiftRadius; }
|
|
|
|
VTKM_CONT void SetPixelShiftRadius(const vtkm::IdComponent& pixelShiftRadius)
|
|
|
|
{
|
|
|
|
this->PixelShiftRadius = pixelShiftRadius;
|
|
|
|
}
|
2020-01-30 00:51:18 +00:00
|
|
|
|
2021-01-05 20:09:01 +00:00
|
|
|
VTKM_CONT vtkm::FloatDefault GetAllowedPixelErrorRatio() const
|
|
|
|
{
|
|
|
|
return this->AllowedPixelErrorRatio;
|
|
|
|
}
|
|
|
|
VTKM_CONT void SetAllowedPixelErrorRatio(const vtkm::FloatDefault& pixelErrorRatio)
|
|
|
|
{
|
|
|
|
this->AllowedPixelErrorRatio = pixelErrorRatio;
|
|
|
|
}
|
2020-01-30 00:51:18 +00:00
|
|
|
|
2021-01-05 20:09:01 +00:00
|
|
|
VTKM_CONT vtkm::FloatDefault GetPixelDiffThreshold() const { return this->PixelDiffThreshold; }
|
|
|
|
VTKM_CONT void SetPixelDiffThreshold(const vtkm::FloatDefault& threshold)
|
2020-01-30 00:51:18 +00:00
|
|
|
{
|
2021-01-05 20:09:01 +00:00
|
|
|
this->PixelDiffThreshold = threshold;
|
2020-01-30 00:51:18 +00:00
|
|
|
}
|
|
|
|
|
2020-05-28 20:36:15 +00:00
|
|
|
VTKM_CONT bool GetImageDiffWithinThreshold() const { return this->ImageDiffWithinThreshold; }
|
2020-01-30 00:51:18 +00:00
|
|
|
VTKM_CONT void SetThresholdFieldName(const std::string& name) { this->ThresholdFieldName = name; }
|
2020-05-28 20:36:15 +00:00
|
|
|
VTKM_CONT std::string GetThresholdFieldName() const { return this->ThresholdFieldName; }
|
2020-01-30 00:51:18 +00:00
|
|
|
|
|
|
|
/// Choose the primary field to operate on. For Image difference A - B, A is the
|
|
|
|
/// primary field.
|
|
|
|
VTKM_CONT
|
|
|
|
void SetPrimaryField(
|
|
|
|
const std::string& name,
|
|
|
|
vtkm::cont::Field::Association association = vtkm::cont::Field::Association::ANY)
|
|
|
|
{
|
|
|
|
this->SetActiveField(name, association);
|
|
|
|
}
|
|
|
|
|
2020-05-28 20:36:15 +00:00
|
|
|
VTKM_CONT std::string GetPrimaryFieldName() const { return this->GetActiveFieldName(); }
|
2020-01-30 00:51:18 +00:00
|
|
|
VTKM_CONT vtkm::cont::Field::Association GetPrimaryFieldAssociation() const
|
|
|
|
{
|
|
|
|
return this->GetActiveFieldAssociation();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Choose the secondary field to operate on. For Image difference A - B, B is the
|
|
|
|
/// secondary field.
|
|
|
|
VTKM_CONT
|
|
|
|
void SetSecondaryField(
|
|
|
|
const std::string& name,
|
|
|
|
vtkm::cont::Field::Association association = vtkm::cont::Field::Association::ANY)
|
|
|
|
{
|
|
|
|
this->SecondaryFieldName = name;
|
|
|
|
this->SecondaryFieldAssociation = association;
|
|
|
|
}
|
|
|
|
|
2020-05-28 20:36:15 +00:00
|
|
|
VTKM_CONT std::string GetSecondaryFieldName() const { return this->SecondaryFieldName; }
|
2020-01-30 00:51:18 +00:00
|
|
|
VTKM_CONT vtkm::cont::Field::Association GetSecondaryFieldAssociation() const
|
|
|
|
{
|
|
|
|
return this->SecondaryFieldAssociation;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
|
|
|
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
|
|
|
const vtkm::cont::ArrayHandle<T, StorageType>& primary,
|
|
|
|
const vtkm::filter::FieldMetadata& fieldMetadata,
|
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
|
|
|
|
|
|
|
private:
|
2021-01-05 20:09:01 +00:00
|
|
|
vtkm::IdComponent AverageRadius;
|
|
|
|
vtkm::IdComponent PixelShiftRadius;
|
|
|
|
vtkm::FloatDefault AllowedPixelErrorRatio;
|
|
|
|
vtkm::FloatDefault PixelDiffThreshold;
|
2020-01-30 00:51:18 +00:00
|
|
|
bool ImageDiffWithinThreshold;
|
|
|
|
std::string SecondaryFieldName;
|
|
|
|
vtkm::cont::Field::Association SecondaryFieldAssociation;
|
|
|
|
std::string ThresholdFieldName;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace filter
|
|
|
|
} // namespace vtkm
|
|
|
|
|
|
|
|
#include <vtkm/filter/ImageDifference.hxx>
|
|
|
|
|
|
|
|
#endif // vtk_m_filter_ImageDifference_h
|