Table of Contents

Class VideoEffectDenoiseCAST

Namespace
VisioForge.Core.Types.VideoEffects
Assembly
VisioForge.Core.dll

Represents a CAST (Content Adaptive Spatio-Temporal) noise reduction effect that provides advanced denoising with extensive parameter control for fine-tuning noise reduction behavior.

public class VideoEffectDenoiseCAST : VideoEffect, IVideoEffectDenoiseCAST, IVideoEffect

Inheritance

Implements

Inherited Members

Remarks

The CAST denoise effect implements a sophisticated content-adaptive spatio-temporal filtering algorithm that analyzes video content across both space (within frames) and time (across frames) to intelligently reduce noise while preserving important visual details. Unlike simpler denoising methods, CAST provides extensive control over filtering parameters, allowing precise optimization for different types of video content and noise characteristics.

SDK Availability: This effect is available in VideoCaptureCore, MediaPlayerCore, and VideoEditCore SDKs. Windows platform only.

Platform Support: Windows only (requires Windows-specific advanced video processing filters).

The algorithm divides frames into blocks and analyzes motion, edges, and noise characteristics within each block. It employs temporal difference detection to identify motion, strong edge detection to preserve important details, and separate processing for edge and non-edge pixels. Gaussian filtering is applied with different thresholds for luminance (Y) and chrominance (UV) channels to account for the human visual system's different sensitivity to noise in brightness versus color information.

Key Features:

  • Block-based motion and edge detection for adaptive filtering
  • Separate edge and non-edge pixel processing to preserve sharpness
  • Independent luminance and chrominance noise reduction
  • Configurable block size for different video resolutions and detail levels
  • History-based temporal filtering with adjustable weight
  • Gaussian filtering with adjustable thresholds for Y and UV channels
  • Ten adjustable parameters for precise control over denoising behavior

Common Use Cases:

  • Professional video post-production requiring maximum quality and control
  • Cleaning up footage from high-ISO camera captures or low-light conditions
  • Removing film grain while preserving fine texture and detail
  • Processing surveillance or security camera footage with persistent noise
  • Preparing video for broadcast or streaming where quality is paramount
  • Restoration of archived video content with age-related noise degradation

Technical Details: The CAST algorithm operates on configurable block sizes, with smaller blocks providing finer detail preservation at the cost of increased processing time. Motion detection uses temporal difference thresholds and pixel count thresholds to identify moving areas where spatial filtering should be emphasized over temporal filtering. Edge detection with configurable strong edge thresholds ensures important details are not smoothed away. The effect buffers multiple frames to build a history for temporal filtering, with the history weight controlling how much past frames influence current frame denoising.

Parameter Tuning Guidelines: Start with default values for most content. Increase temporal difference threshold and number of motion pixels threshold if moving objects show trails or ghosting. Increase strong edge threshold if fine details are being over-smoothed. Adjust block width and height based on video resolution (larger blocks for HD/4K, smaller for SD). Increase gaussian thresholds for more aggressive denoising but watch for loss of texture. Adjust Y and UV thresholds independently to balance luminance and chrominance noise reduction.

For simpler noise reduction with fewer parameters, see VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseAdaptive for automatic adaptive denoising, or VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseMosquito for reducing specific mosquito noise artifacts. Also consider VisioForge.Core.Types.VideoEffects.VideoEffectBlur for basic spatial smoothing or VisioForge.Core.Types.VideoEffects.VideoEffectSmooth for general smoothing effects.

Constructors

VideoEffectDenoiseCAST(bool, string, TimeSpan, TimeSpan)

Initializes a new instance of the VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST class with default parameter values.

public VideoEffectDenoiseCAST(bool enabled, string name = "DenoiseCAST", TimeSpan startTime = default, TimeSpan stopTime = default)

Parameters

enabled bool

true to enable the effect immediately; false to create the effect in a disabled state. The effect can be enabled or disabled later using the VisioForge.Core.Types.VideoEffects.VideoEffect.Enabled property.

name string

An optional name identifier for this effect instance. Default is "DenoiseCAST". Used to retrieve specific effect instances from a collection via the VisioForge.Core.Types.VideoEffects.VideoEffect.Name property. Multiple effects of the same type can coexist with different names.

startTime TimeSpan

The time at which the effect should start being applied. Default is Zero, which applies the effect from the beginning of the video. Use a specific time value to delay the effect start (useful for applying denoising only to specific scenes).

stopTime TimeSpan

The time at which the effect should stop being applied. Default is Zero, which applies the effect until the end of the video. Set to a specific time to limit the effect duration (useful for processing only noisy sections).

Remarks

If both startTime and stopTime are zero (default), the effect will be applied for the entire video duration.

This constructor initializes all CAST parameters to their default values, which provide balanced noise reduction suitable for most content:

  • VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.TemporalDifferenceThreshold = 16
  • VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.NumberOfMotionPixelsThreshold = 16
  • VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.StrongEdgeThreshold = 0 (edge preservation disabled)
  • VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.BlockWidth = 8
  • VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.BlockHeight = 4
  • VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.EdgePixelWeight = 4
  • VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.NonEdgePixelWeight = 128
  • VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.GaussianThresholdY = 16
  • VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.GaussianThresholdUV = 12
  • VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.HistoryWeight = 6

These defaults work well for HD video with moderate noise. Adjust parameters after creation via the property setters to optimize for specific content characteristics. The CAST algorithm requires significant processing power due to its comprehensive analysis; expect processing times to be longer than simpler denoising methods, especially at high resolutions.

Properties

BlockHeight

Gets or sets the block height used for motion and noise analysis.

public int BlockHeight { get; set; }

Property Value

int

Remarks

Works with VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.BlockWidth to define the block size for content analysis. Block height determines the vertical granularity of motion detection and noise reduction. The valid range is more restricted than block width due to processing considerations.

For most content, block height should be similar to block width to avoid directional bias in filtering. However, for video with predominantly horizontal detail (like text or horizontal patterns), smaller block heights may preserve more detail.

BlockWidth

Gets or sets the block width used for motion and noise analysis.

public int BlockWidth { get; set; }

Property Value

int

Remarks

The CAST algorithm divides frames into rectangular blocks for analysis. Block width (along with VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.BlockHeight) determines the granularity of motion detection and edge analysis. Smaller blocks allow finer spatial adaptation to content but increase processing requirements.

Typical values:

  • 4-6: High detail preservation, suitable for SD video or highly detailed content
  • 8-12: Balanced performance and quality (recommended for most HD content)
  • 16-32: Faster processing, suitable for 4K video or when performance is critical
Block width should generally match or be close to block height for optimal results.

EdgePixelWeight

Gets or sets the filtering weight applied to pixels classified as strong edges.

public int EdgePixelWeight { get; set; }

Property Value

int

Remarks

Edge pixels (identified using VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.StrongEdgeThreshold) receive lighter filtering to preserve sharpness and detail. This weight controls how much filtering is applied to edge pixels relative to non-edge pixels (controlled by VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.NonEdgePixelWeight).

Lower values (1-3) apply minimal filtering to edges, maximally preserving sharpness but potentially leaving more noise. Higher values (8-16) apply more filtering to edges, reducing edge noise but potentially softening important details. The default value of 4 provides good balance for most content.

GaussianThresholdUV

Gets or sets the Gaussian filtering threshold for the chrominance (UV) channels.

public int GaussianThresholdUV { get; set; }

Property Value

int

Remarks

Controls Gaussian filtering sensitivity for chrominance (color) information. The human visual system is less sensitive to color noise than brightness noise, so chrominance can typically be filtered more aggressively than luminance. The default value is slightly lower than VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.GaussianThresholdY but can often be increased for more aggressive color noise reduction.

Lower values preserve more color detail and variation but may leave color noise (often appearing as colored speckles in dark areas). Higher values (16-30) smooth color more aggressively, which is often acceptable since the human eye is less sensitive to color variations. Increase this value if color noise is visible, especially in low-light or high-ISO footage.

GaussianThresholdY

Gets or sets the Gaussian filtering threshold for the luminance (Y) channel.

public int GaussianThresholdY { get; set; }

Property Value

int

Remarks

Gaussian filtering is applied to reduce noise while preserving edges. This threshold controls the sensitivity of Gaussian filtering for luminance (brightness) information. The human visual system is more sensitive to luminance noise than chrominance noise, so Y and UV channels are filtered with different thresholds.

Lower values (5-12) apply lighter filtering, preserving more luminance detail but leaving more luminance noise. Higher values (20-40) provide stronger noise reduction but may reduce texture and fine detail. Adjust this independently from VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.GaussianThresholdUV to balance luminance and chrominance noise reduction.

HistoryWeight

Gets or sets the weight applied to historical frame data in temporal filtering.

public int HistoryWeight { get; set; }

Property Value

int

Remarks

Temporal filtering reduces noise by combining information from multiple frames. The history weight determines how much influence previous frames have on the current frame's denoised output. Higher values increase the contribution of historical data, providing stronger noise reduction in static areas but potentially causing more ghosting or trailing in moving areas.

Low values (1-4) minimize temporal artifacts but provide less noise reduction. The default value of 6 balances noise reduction and motion preservation. Higher values (8-16) provide maximum temporal denoising for static content but should be used cautiously if the video contains significant motion. This parameter is most effective when VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.TemporalDifferenceThreshold and VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.NumberOfMotionPixelsThreshold are properly tuned to exclude moving areas from aggressive temporal filtering.

NonEdgePixelWeight

Gets or sets the filtering weight applied to pixels not classified as edges.

public int NonEdgePixelWeight { get; set; }

Property Value

int

Remarks

Non-edge pixels represent smooth areas, gradients, or low-detail regions where aggressive noise reduction can be applied without visible quality loss. This weight determines how strongly these pixels are filtered. Higher values result in stronger smoothing of non-edge areas.

The default value of 128 provides strong noise reduction in smooth areas while allowing VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.EdgePixelWeight to preserve edges. Increase this value if noise persists in smooth areas like skies or walls. Decrease if texture in nominally smooth areas (like faces or fabrics) is being over-smoothed.

NumberOfMotionPixelsThreshold

Gets or sets the threshold for the number of motion pixels required to classify a block as containing motion.

public int NumberOfMotionPixelsThreshold { get; set; }

Property Value

int

Remarks

This parameter works in conjunction with VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.TemporalDifferenceThreshold. After identifying pixels with temporal differences exceeding the threshold, this parameter determines how many such pixels must be present within a block before the entire block is classified as containing motion.

Lower values make motion detection more sensitive, treating blocks with few changed pixels as motion. Higher values require more pixels to change before considering a block as moving, allowing more aggressive temporal filtering in areas with isolated pixel changes (likely noise).

StrongEdgeThreshold

Gets or sets the threshold for detecting strong edges that should be preserved during denoising.

public int StrongEdgeThreshold { get; set; }

Property Value

int

Remarks

Strong edges represent important visual boundaries and fine details that should not be smoothed away during noise reduction. This threshold determines the minimum gradient magnitude for a pixel to be classified as a strong edge pixel. Edge pixels receive different filtering treatment (controlled by VisioForge.Core.Types.VideoEffects.VideoEffectDenoiseCAST.EdgePixelWeight) than non-edge pixels.

A value of 0 (default) disables special edge handling, treating all pixels uniformly. Values of 1-4 provide moderate edge preservation. Values of 5-16 increasingly preserve more subtle edges but may leave more noise around edges. Increase this value if fine details or texture are being over-smoothed.

TemporalDifferenceThreshold

Gets or sets the temporal difference threshold used to detect motion between consecutive frames.

public int TemporalDifferenceThreshold { get; set; }

Property Value

int

Remarks

This threshold determines how much pixel values must differ between consecutive frames to be considered as motion rather than noise. When temporal differences exceed this threshold, the algorithm reduces temporal filtering to avoid motion blur and ghosting artifacts.

Lower values (0-10) make motion detection more sensitive, preserving fast motion but potentially leaving more noise in moving areas. Higher values (20-40) allow stronger temporal filtering but may cause ghosting or trails on fast-moving objects. The default value of 16 works well for most content.

Methods

GetEffectType()

Gets the specific type of this video effect.

public VideoEffectType GetEffectType()

Returns

VideoEffectType

Returns VisioForge.Core.Types.VideoEffects.VideoEffectType.DenoiseCAST to identify this as a CAST denoise effect.

Remarks

This method overrides the base class implementation to provide the concrete effect type. The effect type is used by the video processing pipeline to route the effect to the appropriate CAST denoising filter processor.