Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Implement Feret/Caliper distance metrics in Find Feature Sizes. #948

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Plugins/SimplnxCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set(FilterList
ChangeAngleRepresentationFilter
CombineAttributeArraysFilter
CombineStlFilesFilter
ComputeFeatureRectFilter
CalculateFeatureBoundingBoxesFilter
ComputeMomentInvariants2DFilter
ConditionalSetValueFilter
ConvertColorToGrayScaleFilter
Expand Down Expand Up @@ -148,7 +148,7 @@ set(AlgorithmList
CalculateTriangleGroupCurvatures
CombineAttributeArrays
CombineStlFiles
ComputeFeatureRect
CalculateFeatureBoundingBoxes
ComputeMomentInvariants2D
ConvertColorToGrayScale
ConvertData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Compute Feature Corners
# Calculate Feature Bounding Box

## Group (Subgroup)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "ComputeFeatureRect.hpp"
#include "CalculateFeatureBoundingBoxes.hpp"

#include "simplnx/DataStructure/DataArray.hpp"

Expand All @@ -14,7 +14,8 @@ usize IndexFromCoord(const std::vector<usize>& tDims, usize x, usize y, usize z)
} // namespace

// -----------------------------------------------------------------------------
ComputeFeatureRect::ComputeFeatureRect(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, ComputeFeatureRectInputValues* inputValues)
CalculateFeatureBoundingBoxes::CalculateFeatureBoundingBoxes(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel,
CalculateFeatureBoundingBoxesInputValues* inputValues)
: m_DataStructure(dataStructure)
, m_InputValues(inputValues)
, m_ShouldCancel(shouldCancel)
Expand All @@ -23,16 +24,16 @@ ComputeFeatureRect::ComputeFeatureRect(DataStructure& dataStructure, const IFilt
}

// -----------------------------------------------------------------------------
ComputeFeatureRect::~ComputeFeatureRect() noexcept = default;
CalculateFeatureBoundingBoxes::~CalculateFeatureBoundingBoxes() noexcept = default;

// -----------------------------------------------------------------------------
const std::atomic_bool& ComputeFeatureRect::getCancel()
const std::atomic_bool& CalculateFeatureBoundingBoxes::getCancel()
{
return m_ShouldCancel;
}

// -----------------------------------------------------------------------------
Result<> ComputeFeatureRect::operator()()
Result<> CalculateFeatureBoundingBoxes::operator()()
{
const auto& featureIds = m_DataStructure.getDataRefAs<Int32Array>(m_InputValues->FeatureIdsArrayPath);
auto& corners = m_DataStructure.getDataRefAs<UInt32Array>(m_InputValues->FeatureRectArrayPath);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#pragma once

#include "SimplnxCore/SimplnxCore_export.hpp"

#include "simplnx/DataStructure/DataPath.hpp"
#include "simplnx/DataStructure/DataStructure.hpp"
#include "simplnx/Filter/IFilter.hpp"

namespace nx::core
{

struct SIMPLNXCORE_EXPORT CalculateFeatureBoundingBoxesInputValues
{
DataPath FeatureIdsArrayPath;
DataPath FeatureDataAttributeMatrixPath;
DataPath FeatureRectArrayPath;
};

class SIMPLNXCORE_EXPORT CalculateFeatureBoundingBoxes
{
public:
CalculateFeatureBoundingBoxes(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, CalculateFeatureBoundingBoxesInputValues* inputValues);
~CalculateFeatureBoundingBoxes() noexcept;

CalculateFeatureBoundingBoxes(const CalculateFeatureBoundingBoxes&) = delete;
CalculateFeatureBoundingBoxes(CalculateFeatureBoundingBoxes&&) noexcept = delete;
CalculateFeatureBoundingBoxes& operator=(const CalculateFeatureBoundingBoxes&) = delete;
CalculateFeatureBoundingBoxes& operator=(CalculateFeatureBoundingBoxes&&) noexcept = delete;

Result<> operator()();

const std::atomic_bool& getCancel();

private:
DataStructure& m_DataStructure;
const CalculateFeatureBoundingBoxesInputValues* m_InputValues = nullptr;
const std::atomic_bool& m_ShouldCancel;
const IFilter::MessageHandler& m_MessageHandler;
};

} // namespace nx::core

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "RemoveFlaggedFeatures.hpp"

#include "SimplnxCore/Filters/ComputeFeatureRectFilter.hpp"
#include "SimplnxCore/Filters/CalculateFeatureBoundingBoxesFilter.hpp"
#include "SimplnxCore/Filters/CropImageGeometryFilter.hpp"

#include "simplnx/DataStructure/DataArray.hpp"
Expand Down Expand Up @@ -314,12 +314,12 @@ Result<> RemoveFlaggedFeatures::operator()()
m_MessageHandler(IFilter::ProgressMessage{IFilter::Message::Type::Info, fmt::format("Beginning Feature Extraction")});

{
ComputeFeatureRectFilter filter;
CalculateFeatureBoundingBoxesFilter filter;
Arguments args;

args.insert(ComputeFeatureRectFilter::k_FeatureIdsArrayPath_Key, std::make_any<DataPath>(m_InputValues->FeatureIdsArrayPath));
args.insert(ComputeFeatureRectFilter::k_FeatureDataAttributeMatrixPath_Key, std::make_any<DataPath>(m_InputValues->TempBoundsPath.getParent()));
args.insert(ComputeFeatureRectFilter::k_FeatureRectArrayName_Key, std::make_any<std::string>(m_InputValues->TempBoundsPath.getTargetName()));
args.insert(CalculateFeatureBoundingBoxesFilter::k_FeatureIdsArrayPath_Key, std::make_any<DataPath>(m_InputValues->FeatureIdsArrayPath));
args.insert(CalculateFeatureBoundingBoxesFilter::k_FeatureDataAttributeMatrixPath_Key, std::make_any<DataPath>(m_InputValues->TempBoundsPath.getParent()));
args.insert(CalculateFeatureBoundingBoxesFilter::k_FeatureRectArrayName_Key, std::make_any<std::string>(m_InputValues->TempBoundsPath.getTargetName()));

auto preflightResult = filter.preflight(m_DataStructure, args);
if(preflightResult.outputActions.invalid())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ComputeFeatureRectFilter.hpp"
#include "CalculateFeatureBoundingBoxesFilter.hpp"

#include "SimplnxCore/Filters/Algorithms/ComputeFeatureRect.hpp"
#include "SimplnxCore/Filters/Algorithms/CalculateFeatureBoundingBoxes.hpp"

#include "simplnx/DataStructure/Geometry/IGridGeometry.hpp"
#include "simplnx/Filter/Actions/CreateArrayAction.hpp"
Expand All @@ -16,37 +16,37 @@ using namespace nx::core;
namespace nx::core
{
//------------------------------------------------------------------------------
std::string ComputeFeatureRectFilter::name() const
std::string CalculateFeatureBoundingBoxesFilter::name() const
{
return FilterTraits<ComputeFeatureRectFilter>::name.str();
return FilterTraits<CalculateFeatureBoundingBoxesFilter>::name.str();
}

//------------------------------------------------------------------------------
std::string ComputeFeatureRectFilter::className() const
std::string CalculateFeatureBoundingBoxesFilter::className() const
{
return FilterTraits<ComputeFeatureRectFilter>::className;
return FilterTraits<CalculateFeatureBoundingBoxesFilter>::className;
}

//------------------------------------------------------------------------------
Uuid ComputeFeatureRectFilter::uuid() const
Uuid CalculateFeatureBoundingBoxesFilter::uuid() const
{
return FilterTraits<ComputeFeatureRectFilter>::uuid;
return FilterTraits<CalculateFeatureBoundingBoxesFilter>::uuid;
}

//------------------------------------------------------------------------------
std::string ComputeFeatureRectFilter::humanName() const
std::string CalculateFeatureBoundingBoxesFilter::humanName() const
{
return "Compute Feature Corners";
return "Calculate Feature Bounding Box";
}

//------------------------------------------------------------------------------
std::vector<std::string> ComputeFeatureRectFilter::defaultTags() const
std::vector<std::string> CalculateFeatureBoundingBoxesFilter::defaultTags() const
{
return {className(), "#Statistics", "#Reconstruction", "#Rect", "#Calculate"};
return {className(), "Statistics", "Reconstruction", "Rect", "Calculate", "Find", "Bounding Box"};
}

//------------------------------------------------------------------------------
Parameters ComputeFeatureRectFilter::parameters() const
Parameters CalculateFeatureBoundingBoxesFilter::parameters() const
{
Parameters params;

Expand All @@ -63,14 +63,14 @@ Parameters ComputeFeatureRectFilter::parameters() const
}

//------------------------------------------------------------------------------
IFilter::UniquePointer ComputeFeatureRectFilter::clone() const
IFilter::UniquePointer CalculateFeatureBoundingBoxesFilter::clone() const
{
return std::make_unique<ComputeFeatureRectFilter>();
return std::make_unique<CalculateFeatureBoundingBoxesFilter>();
}

//------------------------------------------------------------------------------
IFilter::PreflightResult ComputeFeatureRectFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler,
const std::atomic_bool& shouldCancel) const
IFilter::PreflightResult CalculateFeatureBoundingBoxesFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler,
const std::atomic_bool& shouldCancel) const
{
auto pFeatureIdsArrayPathValue = filterArgs.value<DataPath>(k_FeatureIdsArrayPath_Key);
auto pFeatureDataAttributeMatrixPathValue = filterArgs.value<DataPath>(k_FeatureDataAttributeMatrixPath_Key);
Expand Down Expand Up @@ -106,16 +106,16 @@ IFilter::PreflightResult ComputeFeatureRectFilter::preflightImpl(const DataStruc
}

//------------------------------------------------------------------------------
Result<> ComputeFeatureRectFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler,
const std::atomic_bool& shouldCancel) const
Result<> CalculateFeatureBoundingBoxesFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler,
const std::atomic_bool& shouldCancel) const
{
ComputeFeatureRectInputValues inputValues;
CalculateFeatureBoundingBoxesInputValues inputValues;

inputValues.FeatureIdsArrayPath = filterArgs.value<DataPath>(k_FeatureIdsArrayPath_Key);
inputValues.FeatureDataAttributeMatrixPath = filterArgs.value<DataPath>(k_FeatureDataAttributeMatrixPath_Key);
inputValues.FeatureRectArrayPath = inputValues.FeatureDataAttributeMatrixPath.createChildPath(filterArgs.value<std::string>(k_FeatureRectArrayName_Key));

return ComputeFeatureRect(dataStructure, messageHandler, shouldCancel, &inputValues)();
return CalculateFeatureBoundingBoxes(dataStructure, messageHandler, shouldCancel, &inputValues)();
}

namespace
Expand All @@ -127,9 +127,9 @@ constexpr StringLiteral k_FeatureRectArrayPathKey = "FeatureRectArrayPath";
} // namespace SIMPL
} // namespace

Result<Arguments> ComputeFeatureRectFilter::FromSIMPLJson(const nlohmann::json& json)
Result<Arguments> CalculateFeatureBoundingBoxesFilter::FromSIMPLJson(const nlohmann::json& json)
{
Arguments args = ComputeFeatureRectFilter().getDefaultArguments();
Arguments args = CalculateFeatureBoundingBoxesFilter().getDefaultArguments();

std::vector<Result<>> results;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@
namespace nx::core
{
/**
* @class ComputeFeatureRectFilter
* @class CalculateFeatureBoundingBoxesFilter
* @brief This filter computes the XYZ minimum and maximum coordinates for each Feature in a segmentation.
* This data can be important for finding the smallest encompassing volume. The values are given in pixel
* coordinates.
*/
class SIMPLNXCORE_EXPORT ComputeFeatureRectFilter : public IFilter
class SIMPLNXCORE_EXPORT CalculateFeatureBoundingBoxesFilter : public IFilter
{
public:
ComputeFeatureRectFilter() = default;
~ComputeFeatureRectFilter() noexcept override = default;
CalculateFeatureBoundingBoxesFilter() = default;
~CalculateFeatureBoundingBoxesFilter() noexcept override = default;

ComputeFeatureRectFilter(const ComputeFeatureRectFilter&) = delete;
ComputeFeatureRectFilter(ComputeFeatureRectFilter&&) noexcept = delete;
CalculateFeatureBoundingBoxesFilter(const CalculateFeatureBoundingBoxesFilter&) = delete;
CalculateFeatureBoundingBoxesFilter(CalculateFeatureBoundingBoxesFilter&&) noexcept = delete;

ComputeFeatureRectFilter& operator=(const ComputeFeatureRectFilter&) = delete;
ComputeFeatureRectFilter& operator=(ComputeFeatureRectFilter&&) noexcept = delete;
CalculateFeatureBoundingBoxesFilter& operator=(const CalculateFeatureBoundingBoxesFilter&) = delete;
CalculateFeatureBoundingBoxesFilter& operator=(CalculateFeatureBoundingBoxesFilter&&) noexcept = delete;

// Parameter Keys
static inline constexpr StringLiteral k_FeatureIdsArrayPath_Key = "feature_ids_array_path";
static inline constexpr StringLiteral k_FeatureRectArrayName_Key = "feature_rect_array_name";
static inline constexpr StringLiteral k_FeatureRectArrayName_Key = "output_bounding_box_array_name";
static inline constexpr StringLiteral k_FeatureDataAttributeMatrixPath_Key = "feature_data_attribute_matrix_path";

/**
Expand Down Expand Up @@ -104,5 +104,5 @@ class SIMPLNXCORE_EXPORT ComputeFeatureRectFilter : public IFilter
};
} // namespace nx::core

SIMPLNX_DEF_FILTER_TRAITS(nx::core, ComputeFeatureRectFilter, "bf947c45-8610-44c9-917a-405e88f73fe7");
SIMPLNX_DEF_FILTER_TRAITS(nx::core, CalculateFeatureBoundingBoxesFilter, "bf947c45-8610-44c9-917a-405e88f73fe7");
/* LEGACY UUID FOR THIS FILTER 6eda8dbf-dbd8-562a-ae1a-f2904157c189 */
Loading
Loading