Class GPUVideoEffectContrast
- Namespace
- VisioForge.Core.Types.VideoEffects
- Assembly
- VisioForge.Core.dll
GPU-accelerated contrast adjustment effect that modifies the tonal range and separation between light and dark areas using DirectX hardware acceleration.
public class GPUVideoEffectContrast : GPUVideoEffect, IGPUVideoEffectContrast, IGPUVideoEffectInheritance
Implements
Inherited Members
Remarks
Available in: VideoCaptureCore, MediaPlayerCore, VideoEditCore (Windows only)
GPU-accelerated version using DirectX. Significantly faster than CPU equivalent for real-time processing of high-resolution video streams.
The contrast effect adjusts the difference between light and dark areas by expanding or compressing the tonal range around a midpoint (typically 128). Increasing contrast makes light areas lighter and dark areas darker, creating more dramatic images with greater visual separation. Decreasing contrast brings all tones closer to middle gray, creating flatter, less dramatic images. The effect uses DirectX compute shaders to apply the contrast formula per-pixel: output = (input - 128) * (contrast / 128) + 128, enabling real-time processing with minimal CPU overhead.
Common use cases include: enhancing image definition and "pop" in flat footage, correcting low-contrast captures, creating dramatic cinematic looks, preparing video for further color grading, reducing contrast for vintage/retro effects, compensating for display limitations, enhancing text/graphics readability over video, and artistic stylization for film noir or high-key lighting effects.
Performance characteristics: GPU acceleration provides near-zero overhead, processing 4K frames in under 1ms on modern GPUs. The operation is compute-efficient and can be chained with other effects without significant performance degradation. Ideal for real-time adjustment during live capture or playback.
Technical notes: Value of 128 represents neutral (no change). Higher values expand the tonal range, potentially causing clipping where highlights exceed 255 or shadows drop below 0, resulting in loss of detail. Lower values compress the tonal range, preserving detail but reducing visual impact. For optimal results, contrast is often combined with brightness adjustment to maintain desired overall exposure while modifying tonal separation. The effect operates independently on each RGB channel, preserving color hue while adjusting luminance relationships.
Cross-reference to CPU equivalent: See VisioForge.Core.Types.VideoEffects.VideoEffectContrast for CPU-based alternative with animation support.
Constructors
GPUVideoEffectContrast(bool, int, string, TimeSpan, TimeSpan)
Initializes a new instance of the VisioForge.Core.Types.VideoEffects.GPUVideoEffectContrast class with specified parameters.
public GPUVideoEffectContrast(bool enabled, int value, string name = "Contrast", TimeSpan startTime = default, TimeSpan stopTime = default)Parameters
enabledbool-
Whether the effect is enabled. Set to
trueto apply immediately,falseto create in disabled state. valueint-
Contrast adjustment value (0-255, neutral at 128). Values outside range are clamped.
namestring-
Optional effect name for identification and retrieval. Default is "Contrast".
startTimeTimeSpan-
Start time for timed effects. Default is zero (apply from beginning).
stopTimeTimeSpan-
Stop time for timed effects. Default is zero (apply until end).
Remarks
When both start and stop times are zero, the effect applies for the entire video duration. The effect type is automatically set to VisioForge.Core.Types.VideoEffects.GPUVideoEffectType.Contrast. For natural results use moderate values (80-180), for artistic effects use extremes but expect potential detail loss.
Properties
Value
Gets or sets the contrast adjustment value (0-255, neutral at 128).
public int Value { get; set; }Property Value
Remarks
Controls the tonal range expansion or compression. Value of 128 represents no change (neutral). Values above 128 expand the tonal range (increased contrast), values below compress it (decreased contrast).
Value ranges: 0 = Minimum contrast (flat gray), 1-127 = Reduced contrast (flatter image), 128 = Neutral (no change), 129-255 = Increased contrast (more dramatic), 255 = Maximum contrast (extreme separation). Higher values may cause clipping where highlights/shadows exceed displayable range, resulting in detail loss.
Methods
GetEffectType()
Gets the specific type of this GPU video effect.
public GPUVideoEffectType GetEffectType()Returns
- GPUVideoEffectType
-
Returns VisioForge.Core.Types.VideoEffects.GPUVideoEffectType.Contrast to identify this as a GPU-accelerated contrast effect.
Remarks
Used by the video processing pipeline to select the appropriate DirectX shader for contrast adjustment processing.