Volume Cartographer 2.27.0
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
volcart::segmentation::OpticalFlowSegmentation Class Reference

Optical Flow Segmentation. More...

#include <vc/segmentation/OpticalFlowSegmentation.hpp>

Inheritance diagram for volcart::segmentation::OpticalFlowSegmentation:
[legend]
Collaboration diagram for volcart::segmentation::OpticalFlowSegmentation:
[legend]

Public Types

using Pointer = std::shared_ptr< OpticalFlowSegmentation >
 
- Public Types inherited from volcart::segmentation::ChainSegmentationAlgorithm
enum class  Status { Success , Failure , ReturnedEarly }
 
using Pointer = std::shared_ptr< ChainSegmentationAlgorithm >
 
using Chain = std::vector< cv::Vec3d >
 
using PointSet = volcart::OrderedPointSet< cv::Vec3d >
 
using Bounds = volcart::BoundingBox< double, 3 >
 

Public Member Functions

 OpticalFlowSegmentation ()=default
 Default constructor.
 
 ~OpticalFlowSegmentation () override=default
 
void setTargetZIndex (int z)
 Set the target z-index.
 
void setOutsideThreshold (std::uint8_t outside)
 Set the threshold of what pixel brightness is considered inside a sheet (higher as threshold) and outside (lower as threshold)
 
void setOFThreshold (std::uint8_t ofThr)
 Set the threshold of what pixel brightness is considered while calculating optical flow, darker pixels OF is interpolated from brighter ones in the area.
 
void setOFDispThreshold (std::uint32_t ofDispThrs)
 Set the maximum single pixel optical flow displacement before interpolating a pixel region.
 
void setSmoothBrightnessThreshold (std::uint8_t brightness)
 Set the threshold for what pixel brightness is considered as being outside the sheet. Pixels above this threshold are considered outside the sheet and are smoothed in an attempt to get them tracking the sheet again.
 
void setMaterialThickness (double m)
 Set the estimated thickness of the substrate (in um) More...
 
void setMaxThreads (std::uint32_t t)
 Set the maximum number of threads.
 
void resetMaxThreads ()
 Clear the maximum number of threads.
 
void setVisualize (bool b)
 
void setDumpVis (bool b)
 
auto compute () -> PointSet override
 Compute the segmentation. More...
 
auto progressIterations () const -> std::size_t override
 Returns the maximum progress value. More...
 
- Public Member Functions inherited from volcart::segmentation::ChainSegmentationAlgorithm
virtual ~ChainSegmentationAlgorithm ()=default
 
auto progressIterations () const -> std::size_t override
 Returns the maximum progress value. More...
 
void setVolume (Volume::Pointer vol)
 Set the input Volume. More...
 
void setBounds (Bounds b)
 Set the bounding box for computation. More...
 
void setChain (Chain c)
 Set the input chain of seed points. More...
 
void setNumberOfSteps (std::size_t n)
 Set the number of propagation steps. More...
 
void setStepSize (double s)
 Set the propagation step size. More...
 
auto getStatus () const -> Status
 Get the status of the previous computation. More...
 
auto getPointSet () const -> const PointSet &
 Get the segmented pointset. More...
 
auto getPointSet () -> PointSet &
 Get the segmented pointset. More...
 
virtual std::size_t progressIterations () const =0
 

Static Public Member Functions

template<typename... Args>
static auto New (Args... args) -> Pointer
 

Private Member Functions

auto compute_curve_ (const FittedCurve &currentCurve, int zIndex) -> std::vector< Voxel >
 Compute the curve for z + 1 given a curve on z using the optical flow between the two slices.
 
auto draw_particle_on_slice_ (const FittedCurve &curve, int sliceIndex, int particleIndex=-1, bool showSpline=false) const -> cv::Mat
 Debug: Draw curve on slice image. More...
 
auto create_final_pointset_ (const std::vector< std::vector< Voxel > > &points) -> PointSet
 Convert the internal storage array into a final PointSet.
 

Private Attributes

int endIndex_ {0}
 
std::uint8_t outsideThreshold_ {80}
 
std::uint8_t opticalFlowPixelThreshold_ {80}
 
std::uint32_t opticalFlowDisplacementThreshold_ {10}
 
std::uint8_t smoothByBrightness_ {180}
 
double materialThickness_ {100}
 
std::optional< std::uint32_t > maxThreads_
 
bool dumpVis_ {false}
 
bool visualize_ {false}
 

Additional Inherited Members

- Public Attributes inherited from volcart::IterationsProgress
Signal progressStarted
 
Signal< std::size_t > progressUpdated
 
Signal progressComplete
 
- Protected Member Functions inherited from volcart::segmentation::ChainSegmentationAlgorithm
 ChainSegmentationAlgorithm ()=default
 
- Protected Attributes inherited from volcart::segmentation::ChainSegmentationAlgorithm
Volume::Pointer vol_
 
Chain startingChain_
 
Bounds bb_
 
std::size_t numSteps_ {0}
 
double stepSize_ {1.0}
 
PointSet result_
 
Status status_ {Status::Success}
 

Detailed Description

Optical Flow Segmentation.

Author
Julian Schilliger (May 2023)

This algorithm propagates a chain of points forward through a volume from a starting z-index to an ending z-index (inclusive). It uses optical flow to track the shape of the layer. Each seed point is assumed to be placed within the layer rather than on its surface boundary.

Warning
This algorithm is non-deterministic and yields slightly different results each run.

Definition at line 31 of file OpticalFlowSegmentation.hpp.

Member Typedef Documentation

◆ Pointer

Pointer

Definition at line 35 of file OpticalFlowSegmentation.hpp.

Constructor & Destructor Documentation

◆ ~OpticalFlowSegmentation()

volcart::segmentation::OpticalFlowSegmentation::~OpticalFlowSegmentation ( )
overridedefault

Default destructor

Member Function Documentation

◆ compute()

auto volcart::segmentation::OpticalFlowSegmentation::compute ( ) -> PointSet
overridevirtual

Compute the segmentation.

Implements volcart::segmentation::ChainSegmentationAlgorithm.

◆ draw_particle_on_slice_()

auto volcart::segmentation::OpticalFlowSegmentation::draw_particle_on_slice_ ( const FittedCurve curve,
int  sliceIndex,
int  particleIndex = -1,
bool  showSpline = false 
) const -> cv::Mat
private

Debug: Draw curve on slice image.

Parameters
curveInput curve
sliceIndexSlice on which to draw
particleIndexHighlight point at particleIndex
showSplineDraw interpolated curve. Default only draws points

◆ New()

template<typename... Args>
static auto volcart::segmentation::OpticalFlowSegmentation::New ( Args...  args) -> Pointer
inlinestatic

Make a new shared instance

Definition at line 45 of file OpticalFlowSegmentation.hpp.

◆ progressIterations()

auto volcart::segmentation::OpticalFlowSegmentation::progressIterations ( ) const -> std::size_t
overridevirtual

Returns the maximum progress value.

Reimplemented from volcart::segmentation::ChainSegmentationAlgorithm.

◆ setDumpVis()

void volcart::segmentation::OpticalFlowSegmentation::setDumpVis ( bool  b)

Debug: Dumps reslices and intensity maps to disk

◆ setMaterialThickness()

void volcart::segmentation::OpticalFlowSegmentation::setMaterialThickness ( double  m)

Set the estimated thickness of the substrate (in um)

Used to generate the radius of the structure tensor calculation

◆ setVisualize()

void volcart::segmentation::OpticalFlowSegmentation::setVisualize ( bool  b)

Debug: Shows intensity maps in GUI window

Member Data Documentation

◆ dumpVis_

bool volcart::segmentation::OpticalFlowSegmentation::dumpVis_ {false}
private

Dump visualization to disk flag

Definition at line 170 of file OpticalFlowSegmentation.hpp.

◆ endIndex_

int volcart::segmentation::OpticalFlowSegmentation::endIndex_ {0}
private

Target z-index

Definition at line 132 of file OpticalFlowSegmentation.hpp.

◆ materialThickness_

double volcart::segmentation::OpticalFlowSegmentation::materialThickness_ {100}
private

Estimated material thickness in um

Definition at line 166 of file OpticalFlowSegmentation.hpp.

◆ maxThreads_

std::optional<std::uint32_t> volcart::segmentation::OpticalFlowSegmentation::maxThreads_
private

Maximum number of threads

Definition at line 168 of file OpticalFlowSegmentation.hpp.

◆ opticalFlowDisplacementThreshold_

std::uint32_t volcart::segmentation::OpticalFlowSegmentation::opticalFlowDisplacementThreshold_ {10}
private

Threshold of how many pixel optical flow can displace a point, if higher, recompute optical flow with region's average flow. This parameter sets the maximum single pixel optical flow displacement before interpolating a pixel region. Range minimum: 0. Higher values allow more displacement before interpolation, while lower values trigger interpolation more frequently.

Definition at line 157 of file OpticalFlowSegmentation.hpp.

◆ opticalFlowPixelThreshold_

std::uint8_t volcart::segmentation::OpticalFlowSegmentation::opticalFlowPixelThreshold_ {80}
private

Disregarding pixel that are darker during optical flow computation. This parameter sets the threshold for what pixel brightness is considered while calculating optical flow. Darker pixels' optical flow is interpolated from brighter ones in the area. Range: 0-255. Higher values disregard more dark pixels during computation, while lower values include more dark pixels.

Definition at line 148 of file OpticalFlowSegmentation.hpp.

◆ outsideThreshold_

std::uint8_t volcart::segmentation::OpticalFlowSegmentation::outsideThreshold_ {80}
private

Darker pixels are considered outside the sheet. This parameter sets the threshold of what pixel brightness is considered too deep inside a sheet (higher than the threshold) and then tries to smoothen those points back towards the edge of the sheet. Range: 0-255.

Definition at line 139 of file OpticalFlowSegmentation.hpp.

◆ smoothByBrightness_

std::uint8_t volcart::segmentation::OpticalFlowSegmentation::smoothByBrightness_ {180}
private

This parameter sets the threshold for what pixel brightness is considered as being outside the sheet. Pixels considered outside the sheet are smoothed in an attempt to get them tracking the sheet again. Range: 0-255. Smooth curve at pixels above this threshold.

Definition at line 164 of file OpticalFlowSegmentation.hpp.

◆ visualize_

bool volcart::segmentation::OpticalFlowSegmentation::visualize_ {false}
private

Show visualization in GUI flag

Definition at line 172 of file OpticalFlowSegmentation.hpp.


The documentation for this class was generated from the following file: