dl::TensorToLine2D
dl::TensorToLine2D
Decodes a tensor channel into a Line2D by thresholding, skeletonization, and ordering. More…
#include <TensorToLine2D.hpp>
Inherits from dl::ChannelDecoder
Public Functions
| Name | |
|---|---|
| virtual std::string | name() const override |
| virtual std::string | outputTypeName() const override |
| Line2D | decode(at::Tensor const & tensor, DecoderContext const & ctx, LineDecoderParams const & params) Decode a tensor channel to an ordered polyline. |
Additional inherited members
Public Functions inherited from dl::ChannelDecoder
| Name | |
|---|---|
| virtual | ~ChannelDecoder() =default |
Detailed Description
class dl::TensorToLine2D;Decodes a tensor channel into a Line2D by thresholding, skeletonization, and ordering.
Strategy:
- Threshold the channel to produce a binary mask
- Skeletonize (thin to 1-pixel width) using Zhang-Suen thinning
- Order skeleton pixels into a connected polyline by tracing connectivity
Output coordinates are scaled from tensor (H, W) back to target_image_size. If target_image_size is {0, 0}, coordinates are returned in tensor space.
Expects a 4D input tensor laid out as [B, C, H, W].
Public Functions Documentation
function name
virtual std::string name() const overrideReimplements: dl::ChannelDecoder::name
function outputTypeName
virtual std::string outputTypeName() const overrideReimplements: dl::ChannelDecoder::outputTypeName
function decode
static Line2D decode(
at::Tensor const & tensor,
DecoderContext const & ctx,
LineDecoderParams const & params
)Decode a tensor channel to an ordered polyline.
Parameters:
- tensor 4D activation tensor [B, C, H, W].
- ctx Decoder indexing context; height and width must match tensor dims 2 and 3.
- params User threshold for line extraction.
Precondition:
- tensor is defined
- tensor.dim() == 4 (layout [B, C, H, W])
- 0 <= ctx.batch_index < tensor.size(0)
- 0 <= ctx.source_channel < tensor.size(1)
- ctx.height > 0 and ctx.width > 0
- tensor.size(2) == ctx.height and tensor.size(3) == ctx.width
Postcondition: Returned line is empty when no pixels exceed params.threshold.
Updated on 2026-11-13 at 20:25:42 +0000