dl::TensorToMask2D
dl::TensorToMask2D
Decodes a tensor channel into a Mask2D by thresholding. More…
#include <TensorToMask2D.hpp>
Inherits from dl::ChannelDecoder
Public Functions
| Name | |
|---|---|
| virtual std::string | name() const override |
| virtual std::string | outputTypeName() const override |
| Mask2D | decode(at::Tensor const & tensor, DecoderContext const & ctx, MaskDecoderParams const & params) Decode a tensor channel to a mask by thresholding. |
Additional inherited members
Public Functions inherited from dl::ChannelDecoder
| Name | |
|---|---|
| virtual | ~ChannelDecoder() =default |
Detailed Description
class dl::TensorToMask2D;Decodes a tensor channel into a Mask2D by thresholding.
All pixels with activation above params.threshold are collected as mask pixels. Output pixel 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 Mask2D decode(
at::Tensor const & tensor,
DecoderContext const & ctx,
MaskDecoderParams const & params
)Decode a tensor channel to a mask by thresholding.
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 mask generation.
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 mask contains only pixels with activation > params.threshold.
Updated on 2026-11-13 at 20:25:42 +0000