Skip to content

Commit

Permalink
CubicSplineMT: Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
csparker247 committed Aug 26, 2024
1 parent a5ea6bb commit 4a9f3b8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
1 change: 1 addition & 0 deletions cmake/Buildthreadpool.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ FetchContent_Declare(
threadpool
GIT_REPOSITORY https://github.com/bshoshany/thread-pool.git
GIT_TAG v4.1.0
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(threadpool)
3 changes: 2 additions & 1 deletion segmentation/include/vc/segmentation/lrps/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <algorithm>
#include <tuple>
#include <vector>

#include <opencv2/core.hpp>

#define BGR_RED cv::Scalar(0, 0, 0xFF)
Expand All @@ -15,7 +16,7 @@
#define BGR_BLACK cv::Scalar(0, 0, 0)

using IndexIntensityPair = std::pair<int, double>;
using IndexIntensityPairVec = typename std::vector<IndexIntensityPair>;
using IndexIntensityPairVec = std::vector<IndexIntensityPair>;
using Voxel = cv::Vec3d;
using Pixel = cv::Vec2d;

Expand Down
25 changes: 21 additions & 4 deletions segmentation/include/vc/segmentation/lrps/CubicSplineMT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,32 @@

#include <mutex>
#include <vector>
#include <cstddef>

#include "vc/segmentation/lrps/Common.hpp"

namespace volcart::segmentation
{

/**
* @brief Thread-safe cubic spline
* @brief Multi-threaded cubic spline
*
* @author Julian Schilliger
* @date September 2023
* @copyright 2023 Julian Schilliger, MIT License.
*
* @details Cubic spline class which uses multiple threads to fit to the
* provided knots.
*/
class CubicSplineMT
{
public:
/** Default constructor */
CubicSplineMT() = default;
CubicSplineMT(const std::vector<double>&(x), const std::vector<double>&(y));
/** Construct and fit to separated x, y knot pairs */
CubicSplineMT(const std::vector<double>& x, const std::vector<double>& y);
/** Construct and fit to a set of know */
explicit CubicSplineMT(const std::vector<Voxel>& vs);
/** Default destructor */
~CubicSplineMT() = default;

/** Copy constructor */
Expand All @@ -35,10 +44,18 @@ class CubicSplineMT
auto operator()(double t) const -> Pixel;

private:
/** x params */
std::vector<double> aX_, bX_, cX_, dX_;
/** y params */
std::vector<double> aY_, bY_, cY_, dY_;
/** Percent position of knots in total number of knots */
std::vector<double> rangeXY_;
/** Lengths of subsegments */
std::vector<double> subsegLens_;
/** Cumulative lengths of subsegments */
std::vector<double> cumuLens_;
/** Parameter write mutex */
std::mutex mtx_;
};
};

} // namespace volcart::segmentation
1 change: 1 addition & 0 deletions segmentation/src/CubicSplineMT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <algorithm>
#include <cmath>
#include <cstddef>
#include <future>
#include <iostream>
#include <mutex>
Expand Down
2 changes: 0 additions & 2 deletions segmentation/test/CubicSplineTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ struct ParabolicCubicSpline {

////////////////////////////////////////////////////////////////////////////////
// Test tval generation
// Note: use BOOST_REQUIRE_* here so we don't go on to other tests if this check
// fails since those tests rely on this functionality
TEST(CubicSplineTest, CanGenerateCorrectTValues)
{
// Create N t-values to evaluate the spline at and make sure we get a
Expand Down

0 comments on commit 4a9f3b8

Please sign in to comment.