|
Volume Cartographer 2.28.0
|
Optical Flow Segmentation. More...
#include <vc/segmentation/OpticalFlowSegmentation.hpp>
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 = OrderedPointSet< cv::Vec3d > |
| using | Bounds = BoundingBox< double, 3 > |
Public Member Functions | |
| OpticalFlowSegmentation ()=default | |
| Default constructor. | |
| ~OpticalFlowSegmentation () override=default | |
| void | setStartZIndex (int z) |
| Set the start z-index. | |
| auto | getStartZIndex () const -> int |
| Get the start z-index. | |
| void | setTargetZIndex (int z) |
| Set the target z-index. | |
| auto | getTargetZIndex () const -> int |
| Get 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 | setEnableSmoothOutliers (bool enable) |
| Set whether to enable outlier points smoothening. | |
| void | setEnableEdgeDetection (bool enable) |
| Set whether to enable edge detection. | |
| void | setEdgeJumpDistance (std::uint32_t distance) |
| Set the minimum jump distance for edge detection. | |
| void | setEdgeBounceDistance (std::uint32_t distance) |
| Set the maximum bounce distance for edge detection. | |
| void | setInterpolate (bool b) |
| Set whether to interpolate against the master cloud. | |
| void | setInterpolationWindow (std::uint32_t window) |
| Set how wide the interpolation window should be. | |
| auto | getInterpolationWindow () const -> std::uint32_t |
| Get how wide the interpolation window should be. | |
| void | setInterpolationDistance (std::uint32_t distance) |
| Set how many slices the interpolation center is away from the start slice. | |
| auto | getInterpolationDistance () const -> std::uint32_t |
| Get how many slices the interpolation center is away from the start slice. | |
| void | setMasterCloud (PointSet masterCloud) |
| Set the already computed masterCloud OrderedPointSet. | |
| void | setReSegmentationChain (Chain c) |
| Set the input chain of re-segmentation points. | |
| 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 | |
| ~ChainSegmentationAlgorithm () override=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 ¤tCurve, int zIndex) const -> std::vector< Voxel > |
| Compute the curve for z + 1 given a curve on z using the optical flow between the two slices. | |
| auto | interpolate_ (int interpStart, int interpEnd, int startChain, int startResegChain) -> std::vector< std::vector< Voxel > > |
| Blend the re-segmentation run into the forward run over an interpolation window. More... | |
| auto | run_ofs_ (Chain currentVs, int startChainIndex, int anchorEndIdx, int targetIndex, int stepAdjustment, std::size_t &iteration, bool backwards, const filesystem::path &debugDir) -> std::tuple< std::vector< std::vector< Voxel > >, Status > |
| Run the optical flow segmentation in one direction. More... | |
Private Attributes | |
| int | startIndex_ {0} |
| int | endIndex_ {0} |
| std::uint8_t | outsideThreshold_ {80} |
| std::uint8_t | opticalFlowPixelThreshold_ {80} |
| std::uint32_t | opticalFlowDisplacementThreshold_ {10} |
| std::uint8_t | smoothByBrightness_ {180} |
| bool | enableSmoothenOutlier_ {true} |
| bool | enableEdge_ {false} |
| std::uint32_t | edgeJumpDistance_ {6} |
| std::uint32_t | edgeBounceDistance_ {3} |
| bool | requestInterp_ {false} |
| std::uint32_t | interpWindow_ {5} |
| std::uint32_t | interpDist_ {25} |
| Chain | resegStartingChain_ |
| PointSet | masterCloud_ |
| 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} |
Optical Flow Segmentation.
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.
Definition at line 32 of file OpticalFlowSegmentation.hpp.
| using volcart::segmentation::OpticalFlowSegmentation::Pointer = std::shared_ptr<OpticalFlowSegmentation> |
Pointer
Definition at line 36 of file OpticalFlowSegmentation.hpp.
|
overridedefault |
Default destructor
|
overridevirtual |
Compute the segmentation.
Implements volcart::segmentation::ChainSegmentationAlgorithm.
|
private |
Blend the re-segmentation run into the forward run over an interpolation window.
| interpStart | First z-slice of the interpolation window |
| interpEnd | Last z-slice of the interpolation window |
| startChain | Z-index of the primary starting chain |
| startResegChain | Z-index of the re-segmentation starting chain |
|
inlinestatic |
Make a new shared instance
Definition at line 46 of file OpticalFlowSegmentation.hpp.
|
overridevirtual |
Returns the maximum progress value.
Reimplemented from volcart::segmentation::ChainSegmentationAlgorithm.
|
private |
Run the optical flow segmentation in one direction.
| currentVs | Starting chain of points |
| startChainIndex | Z-index of the starting chain |
| anchorEndIdx | Z-index at which to stop and return |
| targetIndex | Final target z-index (used for bounds checking) |
| stepAdjustment | Initial step offset to align with the grid |
| iteration | Running progress counter (updated in place) |
| backwards | True to propagate toward lower z-indices |
| debugDir | Root directory for debug visualizations |
| void volcart::segmentation::OpticalFlowSegmentation::setDumpVis | ( | bool | b | ) |
Debug: Dumps reslices and intensity maps to disk
| 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
| void volcart::segmentation::OpticalFlowSegmentation::setVisualize | ( | bool | b | ) |
Debug: Shows intensity maps in GUI window
|
private |
Dump visualization to disk flag
Definition at line 259 of file OpticalFlowSegmentation.hpp.
|
private |
Maximum displacement (voxels) allowed as a bounce from an edge
Definition at line 243 of file OpticalFlowSegmentation.hpp.
|
private |
Minimum displacement (voxels) considered an edge jump
Definition at line 241 of file OpticalFlowSegmentation.hpp.
|
private |
Enable edge detection to constrain point movement
Definition at line 239 of file OpticalFlowSegmentation.hpp.
|
private |
Enable smoothing of detected outlier points
Definition at line 237 of file OpticalFlowSegmentation.hpp.
|
private |
Target z-index
Definition at line 203 of file OpticalFlowSegmentation.hpp.
|
private |
Distance in slices from the start slice to the interpolation center
Definition at line 249 of file OpticalFlowSegmentation.hpp.
|
private |
Half-width of the interpolation window in slices (must be positive)
Definition at line 247 of file OpticalFlowSegmentation.hpp.
|
private |
Pre-computed master cloud used for interpolation blending
Definition at line 253 of file OpticalFlowSegmentation.hpp.
|
private |
Estimated material thickness in um
Definition at line 255 of file OpticalFlowSegmentation.hpp.
|
private |
Maximum number of threads
Definition at line 257 of file OpticalFlowSegmentation.hpp.
|
private |
Threshold of how many pixels 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 228 of file OpticalFlowSegmentation.hpp.
|
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 219 of file OpticalFlowSegmentation.hpp.
|
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 210 of file OpticalFlowSegmentation.hpp.
|
private |
Enable blending of OFS output against the master cloud
Definition at line 245 of file OpticalFlowSegmentation.hpp.
|
private |
Re-segmentation starting chain provided by the caller
Definition at line 251 of file OpticalFlowSegmentation.hpp.
|
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 235 of file OpticalFlowSegmentation.hpp.
|
private |
Start z-index
Definition at line 201 of file OpticalFlowSegmentation.hpp.
|
private |
Show visualization in GUI flag
Definition at line 261 of file OpticalFlowSegmentation.hpp.