Video processing
ITK video processing treats a temporal image sequence as a stream of image frames. It connects frame-aware data regions to file, camera, and image-sequence input; temporal filters; and file or external-library output. The design lets a pipeline request only the frames and spatial areas that it needs while keeping frame geometry and pixel type available to downstream filters.
Processing model
Temporal image sequences
A video is a sequence of image frames with a temporal extent. The temporal extent can be described by frame number, real time, or both, so a pipeline can work with indexed samples while preserving timing information when the source provides it. See the temporal data child page for the full temporal-region model. Modules/…/itkTemporalRegion.h• L35-43 Modules/…/itkTemporalDataObject.h• L52-63
The video core also accepts an n-dimensional image as a source of frames. ImageToVideoFilter assigns one image axis to time and presents the remaining axes as each frame. This gives image-based data a direct path into a temporal pipeline. Modules/…/itkImageToVideoFilter.h• L30-48 Modules/Video/Core/include/itkImageToVideoFilter.hxx#L95-L145
Wrapped bindings expose ImageToVideoFilter only for input dimensions that produce supported frame dimensions. The wrapper excludes the lowest configured image dimension and provides scalar and vector-image forms, so the wrapped API stays aligned with the VideoStream frame model. Modules/Video/Core/wrapping/itkImageToVideoFilter.wrap#L1-L25
References: Modules/…/itkTemporalRegion.h• L35-43 Modules/…/itkTemporalDataObject.h• L52-63 Modules/…/itkImageToVideoFilter.h• L30-48 Modules/…/itkImageToVideoFilter.hxx• L95-145 Modules/…/itkImageToVideoFilter.wrap• L1-25
Frame storage and metadata
VideoStream is the image-specific temporal data object. It holds a buffered window of frames and keeps the logical temporal extent separate from the frames that are resident in memory. A ring buffer supports this windowed model, which is important for long sequences and filters that use a small temporal neighborhood. Modules/…/itkVideoStream.h• L27-37 Modules/…/itkTemporalDataObject.h• L52-63 Modules/…/itkRingBuffer.h• L27-35
Each frame has its own spatial region and image metadata. The stream also caches this information by frame number, so a pipeline can describe frames before it loads their pixels. This permits sequences with frame-specific spatial information instead of forcing every frame into one shared image description. Modules/…/itkVideoStream.h• L31-37 Modules/…/itkVideoStream.h• L118-191
References: Modules/…/itkVideoStream.h• L27-37 Modules/…/itkVideoStream.h• L68-73 Modules/…/itkVideoStream.h• L118-191 Modules/…/itkRingBuffer.h• L27-35
Temporal and spatial requests
Video pipeline requests have two linked parts: a temporal region selects frames and a spatial region selects pixels within those frames. TemporalProcessObject uses the requested output region to form the input request that a source must provide. VideoSource prepares the requested output frames and their spatial buffers before threaded processing. A filter can therefore consume a multi-frame stencil without loading the whole sequence. Modules/…/itkTemporalProcessObject.h• L84-93 Modules/…/itkTemporalProcessObject.h• L127-147 Modules/…/itkVideoSource.h• L35-39 Modules/Video/Core/include/itkVideoSource.hxx#L138-L175 Modules/Video/Core/include/itkVideoSource.hxx#L184-L215
VideoToVideoFilter carries both temporal and spatial requests between video streams. Its default behavior maps the first requested output spatial region to the input frames, while filters with different needs can define another mapping. Readers and filters use the buffered temporal region to distinguish data that is available from data that must be produced upstream. Modules/…/itkVideoToVideoFilter.h• L27-41 Modules/…/itkTemporalDataObject.h• L120-141
References: Modules/…/itkTemporalProcessObject.h• L84-93 Modules/…/itkTemporalProcessObject.h• L127-147 Modules/…/itkTemporalProcessObject.h• L179-202 Modules/…/itkVideoSource.h• L35-39 Modules/…/itkVideoSource.hxx• L138-175 Modules/…/itkVideoSource.hxx• L184-215 Modules/…/itkVideoToVideoFilter.h• L93-125 Modules/…/itkTemporalDataObject.h• L120-141
Input and output
Video readers
Modules/…/itkVideoFileReader.h is the pipeline source for video files. It creates a VideoStream, publishes frame dimensions and temporal metadata, and loads the requested frame into the stream buffer. The reader can convert source component types and channel counts to the output frame type when the selected IO supplies a different representation. Modules/…/itkVideoFileReader.h• L28-39 Modules/Video/IO/include/itkVideoFileReader.hxx#L43-L109 Modules/Video/IO/include/itkVideoFileReader.hxx#L205-L247
The reader exposes position, frame count, and frame-rate information from its VideoIOBase. Its safe-frame mode can limit the reported largest temporal region to the last frame that the backend can seek to reliably. This protects downstream requests from backend seek limits such as key-frame-only access. Modules/…/itkVideoFileReader.h• L84-116 Modules/Video/IO/include/itkVideoFileReader.hxx#L66-L76
References: Modules/…/itkVideoFileReader.h• L28-39 Modules/…/itkVideoFileReader.h• L79-116 Modules/…/itkVideoFileReader.hxx• L43-109 Modules/…/itkVideoFileReader.hxx• L168-247
Video writers
Modules/…/itkVideoFileWriter.h is the pipeline sink for a VideoStream. It requests the selected temporal range from upstream and sends its frames in order to a VideoIOBase writer. Without an explicit output range it writes the input's largest possible temporal region. Modules/…/itkVideoFileWriter.h• L28-37 Modules/…/itkVideoFileWriter.h• L102-120
Writing needs output dimensions, component count, frame rate, and a FourCC codec code. The writer obtains dimensions and pixel information from the input frames, while the caller supplies the timing and codec choices. The backend then turns each requested frame into the target file representation. Modules/…/itkVideoFileWriter.h• L67-100 Modules/Video/IO/include/itkVideoFileWriter.hxx#L78-L181 Modules/Video/IO/include/itkVideoFileWriter.hxx#L238-L292
References: Modules/…/itkVideoFileWriter.h• L28-37 Modules/…/itkVideoFileWriter.h• L67-120 Modules/…/itkVideoFileWriter.hxx• L78-181 Modules/…/itkVideoFileWriter.hxx• L214-236
IO selection
VideoIOBase defines the common contract for reading files or cameras and for writing encoded frames. VideoIOFactory selects a registered backend by asking whether it can read the requested file or camera, or write the requested file. This keeps the reader and writer independent of OpenCV, VXL, or image-file details. Modules/…/itkVideoIOBase.h• L50-68 Modules/…/itkVideoIOFactory.h• L50-57 Modules/Video/IO/src/itkVideoIOFactory.cxx#L24-L80
The available backend depends on registration and capability checks. A backend must be present in the build and registered with the object factory before CreateVideoIO can return it. Applications can also provide a backend explicitly to a reader or writer when automatic selection is not suitable. Modules/…/itkVideoIOFactory.h• L81-87 Modules/…/itkVideoFileReader.h• L95-98 Modules/…/itkVideoFileWriter.h• L98-100
References: Modules/…/itkVideoIOBase.h• L50-68 Modules/…/itkVideoIOBase.h• L96-154 Modules/…/itkVideoIOFactory.h• L50-87 Modules/…/itkVideoIOFactory.cxx• L24-80
Frame-file sequences
FileListVideoIO treats a comma-separated list of image files as one logical video. It uses the regular image IO system for each frame, reports a frame rate of one for the sequence, and keeps the image geometry from the selected image format. This path is useful when a temporal sequence exists as separate image files rather than as an encoded video container. Modules/…/itkFileListVideoIO.h• L26-37 Modules/Video/IO/src/itkFileListVideoIO.cxx#L36-L79 Modules/Video/IO/src/itkFileListVideoIO.cxx#L135-L180
The list must contain compatible file names, and the selected image IO must support the first file for the requested operation. The same interface can write a sequence of image files when the output names and image writer are valid. Modules/Video/IO/src/itkFileListVideoIO.cxx#L101-L126 Modules/Video/IO/src/itkFileListVideoIO.cxx#L264-L289 Modules/Video/IO/src/itkFileListVideoIO.cxx#L322-L355
References: Modules/…/itkFileListVideoIO.h• L26-37 Modules/…/itkFileListVideoIO.h• L60-78 Modules/…/itkFileListVideoIO.cxx• L36-79 Modules/…/itkFileListVideoIO.cxx• L101-126 Modules/…/itkFileListVideoIO.cxx• L264-355
Filtering
Temporal filter behavior
Video filters use the same pipeline style as image filters but declare how many input frames produce each output frame. The temporal process base splits a larger request into smaller temporal operations, advances the input stencil according to the filter's frame step, and lets the filter work on one temporal unit at a time. See filtering framework for the shared pipeline rules and video filter workflows for temporal filter use. Modules/…/itkTemporalProcessObject.h• L31-62 Modules/…/itkTemporalProcessObject.h• L127-202
VideoSource allocates the requested frame regions, prepares the output stream, and runs the filter's frame work through spatial pieces that can execute in parallel. The temporal request remains the context for each piece, so a filter can use neighboring frames while keeping the image pipeline's spatial region model. Modules/Video/Core/include/itkVideoSource.hxx#L184-L243 Modules/Video/Core/include/itkVideoSource.hxx#L259-L356 Modules/…/itkVideoToVideoFilter.h• L112-131
References: Modules/…/itkTemporalProcessObject.h• L31-62 Modules/…/itkTemporalProcessObject.h• L127-202 Modules/…/itkVideoSource.hxx• L184-243 Modules/…/itkVideoSource.hxx• L259-356 Modules/…/itkVideoToVideoFilter.h• L112-131
Temporal filter set
The built-in video filters cover common changes to a temporal sequence. They preserve the frame image model while changing the temporal sampling or deriving values from a group of frames.
| Filter | Temporal purpose |
|---|---|
FrameAverageVideoFilter | Replaces a sliding group of frames with one per-pixel average frame. |
FrameDifferenceVideoFilter | Produces a per-pixel squared difference between frames separated by a configurable offset. |
DecimateFramesVideoFilter | Keeps every configured Nth frame to reduce temporal sampling. |
These filters are VideoToVideoFilter processes. Their input-frame count and frame step define the temporal contract that upstream readers and filters must satisfy. Modules/…/itkFrameAverageVideoFilter.h• L26-36 Modules/…/itkFrameDifferenceVideoFilter.h• L26-37 Modules/…/itkDecimateFramesVideoFilter.h• L26-37 Modules/Video/Filtering/include/itkFrameAverageVideoFilter.hxx#L32-L46 Modules/Video/Filtering/include/itkFrameDifferenceVideoFilter.hxx#L32-L46 Modules/Video/Filtering/include/itkDecimateFramesVideoFilter.hxx#L30-L40
References: Modules/…/itkFrameAverageVideoFilter.h• L26-36 Modules/…/itkFrameDifferenceVideoFilter.h• L26-37 Modules/…/itkDecimateFramesVideoFilter.h• L26-37 Modules/…/itkFrameAverageVideoFilter.hxx• L93-143 Modules/…/itkFrameDifferenceVideoFilter.hxx• L96-141 Modules/…/itkDecimateFramesVideoFilter.hxx• L86-115
Image filter reuse
ImageFilterToVideoFilterWrapper adapts an ordinary ITK image-to-image filter to a video-to-video connection. It sends one frame through the image filter for each temporal operation and places the image result into the matching output frame. This gives existing image algorithms a path into video workflows without changing their image-level contract. Modules/…/itkImageFilterToVideoFilterWrapper.h• L26-37 Modules/Video/Filtering/include/itkImageFilterToVideoFilterWrapper.hxx#L47-L80
The wrapper is a one-frame-in, one-frame-out process. It does not add temporal context to an image filter, so algorithms that need neighboring frames should use a temporal filter contract instead. Modules/Video/Filtering/include/itkImageFilterToVideoFilterWrapper.hxx#L25-L32 Modules/…/itkVideoToVideoFilter.h• L27-41
References: Modules/…/itkImageFilterToVideoFilterWrapper.h• L26-43 Modules/…/itkImageFilterToVideoFilterWrapper.h• L64-85 Modules/…/itkImageFilterToVideoFilterWrapper.hxx• L47-80 Modules/…/itkVideoToVideoFilter.h• L27-41
External library bridges
OpenCV video bridge
The OpenCV bridge supplies a VideoIOBase backend for OpenCV video files and camera devices. OpenCVVideoIO maps OpenCV capture and writer properties to ITK frame and timing data. OpenCVVideoIOFactory registers that backend with the common video IO contract, so automatic selection can use it when the module is available. Modules/…/itkOpenCVVideoIO.h• L30-37 Modules/…/itkOpenCVVideoIOFactory.h• L27-33 Modules/Video/BridgeOpenCV/src/itkOpenCVVideoIOFactory.cxx#L24-L28
The bridge module carries OpenCV discovery settings into both build-tree and installed use. This keeps the OpenCV dependency available when an application loads the bridge and exposes its include and library locations to the module. Modules/…/CMakeLists.txt• L5-28
The backend exposes file and camera reads, frame seeking, timing, and video writing through the same interface used by the video reader and writer. It supplies default spatial metadata because OpenCV does not provide this video metadata through the bridge. Modules/…/itkOpenCVVideoIO.h• L62-110 Modules/…/itkOpenCVVideoIO.h• L116-161
OpenCVVideoCapture provides the reverse boundary. It presents an ITK VideoStream through the cv::VideoCapture API, so OpenCV code can grab and retrieve frames produced by an ITK pipeline. Its file and device open methods are intentionally unavailable because ordinary OpenCV capture should be used for those sources. Modules/…/itkOpenCVVideoCapture.h• L38-49 Modules/…/itkOpenCVVideoCapture.h• L72-123
References: Modules/…/itkOpenCVVideoIO.h• L30-37 Modules/…/itkOpenCVVideoIO.h• L62-161 Modules/…/itkOpenCVVideoIOFactory.h• L27-63 Modules/…/itkOpenCVVideoIOFactory.cxx• L24-28 Modules/…/itkOpenCVVideoCapture.h• L38-49 Modules/…/itkOpenCVVideoCapture.h• L72-123 Modules/…/CMakeLists.txt• L5-28
OpenCV image bridge
OpenCVImageBridge converts individual images between ITK and OpenCV types. It copies pixels when needed and handles supported scalar and color-channel conversions, including the RGB and BGR order difference. This bridge is the image-level companion to the OpenCV video IO path. Modules/…/itkOpenCVImageBridge.h• L42-56 Modules/…/itkOpenCVImageBridge.h• L65-83 Modules/…/itkOpenCVImageBridge.h• L151-202
The bridge also provides conversions for common geometry and value types such as points, indices, sizes, fixed-size matrices, and vectors. These conversions preserve matching dimensions and component types across the ITK and OpenCV representations. Callers must use supported dimensions and matching component types because unsupported combinations raise an error rather than silently changing the data. Modules/…/itkOpenCVBasicTypeBridge.h• L37-65 Modules/…/itkOpenCVBasicTypeBridge.h• L94-207 Modules/…/itkOpenCVImageBridge.h• L204-219
For the wider boundary between ITK types and external languages or libraries, see language and library bridges. Modules/…/itkOpenCVBasicTypeBridge.h• L167-209
References: Modules/…/itkOpenCVImageBridge.h• L42-56 Modules/…/itkOpenCVImageBridge.h• L65-83 Modules/…/itkOpenCVImageBridge.h• L151-219 Modules/…/itkOpenCVBasicTypeBridge.h• L37-65 Modules/…/itkOpenCVBasicTypeBridge.h• L94-207
VXL video bridge
The VXL bridge supplies another VideoIOBase backend for video files. VXLVideoIO maps VXL and FFmpeg stream properties, decoded frames, and encoded output to the ITK video contract. VXLVideoIOFactory registers this backend with the same object-factory path used for other video IO backends. Modules/…/itkVXLVideoIO.h• L34-42 Modules/…/itkVXLVideoIOFactory.h• L26-32 Modules/Video/BridgeVXL/src/itkVXLVideoIOFactory.cxx#L24-L27
The backend exposes file reads and writes, frame position and timing data, and pixel-format checks through VideoIOBase. Camera access remains part of the shared interface but is not provided by this VXL bridge. Modules/…/itkVXLVideoIO.h• L66-145 Modules/…/itkVXLVideoIO.h• L171-185
References: Modules/…/itkVXLVideoIO.h• L34-42 Modules/…/itkVXLVideoIO.h• L66-145 Modules/…/itkVXLVideoIO.h• L171-185 Modules/…/itkVXLVideoIOFactory.h• L26-62 Modules/…/itkVXLVideoIOFactory.cxx• L24-27
Pipeline flow
Video processing lifecycle
The video lifecycle starts with a backend-specific source and ends with a backend-specific sink. Between them, temporal requests select the needed frames, and video filters transform those frames without coupling the pipeline to the file or camera library.
This diagram shows how a source becomes an ITK stream, passes through temporal processing, and returns to an external video or frame-file representation.
flowchart LR
S[File, camera, or image-file list] --> F[VideoIOFactory]
F --> R[VideoFileReader]
R --> V[VideoStream]
V --> T[Temporal and spatial requests]
T --> P[Video filters]
P --> W[VideoFileWriter]
W --> O[VideoIO backend]
O --> D[Encoded video or frame-file sequence]
The reader and writer own the external IO boundary. The video core owns temporal regions, frame buffering, and pipeline requests, while filtering modules own frame-to-frame or frame-window operations. The OpenCV capture bridge adds a second output boundary for applications that want to consume an ITK-produced stream through OpenCV. Modules/…/itkVideoFileReader.h• L28-39 Modules/…/itkTemporalProcessObject.h• L127-147 Modules/…/itkVideoFileWriter.h• L28-37 Modules/…/itkOpenCVVideoCapture.h• L38-49
References: Modules/…/itkVideoFileReader.h• L28-39 Modules/…/itkVideoIOFactory.h• L81-87 Modules/…/itkTemporalProcessObject.h• L127-147 Modules/…/itkVideoSource.hxx• L184-243 Modules/…/itkImageFilterToVideoFilterWrapper.h• L26-37 Modules/…/itkVideoFileWriter.h• L28-37 Modules/…/itkOpenCVVideoCapture.h• L38-49
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to
TemporalRegionor temporal-unit behavior must stay aligned acrossVideoStream, temporal request propagation, source output preparation, reader seek behavior, filter stencils, and writer output ranges. - Changes to source output allocation or spatial splitting must preserve the requested regions for all frames and the temporal context seen by threaded filter work.
- Changes to per-frame spatial metadata must preserve the agreement between cached stream metadata, allocated frame regions, image-to-video conversion, and external image bridges.
- Changes to a
VideoIOBasecapability or file test must update factory registration and theCanReadFile,CanReadCamera, andCanWriteFileselection contract. - Changes to channel order or component support must stay consistent across reader conversion, OpenCV matrix conversion, VXL pixel formats, and writer input limits.
- Changes to a filter's input-frame count or frame step must remain consistent with its requested temporal region and with downstream assumptions about output frame numbers.
- Changes to the image-file-list format must preserve both comma-separated frame parsing and the image IO requirements for every frame in the sequence.
- Changes to OpenCV or VXL factory registration must preserve the
itkVideoIOBaseoverride name and make the factory available before automatic video IO selection. - Changes to OpenCV bridge dependency export must preserve OpenCV discovery for both build-tree and installed consumers, including platform-specific OpenCV options.
- Changes to OpenCV capture use must preserve the boundary between ITK-stream input and ordinary file or device capture through
cv::VideoCapture. - Changes to VXL pixel-format or camera capability rules must stay aligned with the shared
VideoIOBasecontract and backend selection checks. - Changes to wrapped
ImageToVideoFilterdimensions or template forms must preserve the supported frame dimension andVideoStreamtype mapping.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| No registered backend accepts the file, camera, or output name | VideoFileReader or VideoFileWriter cannot create a VideoIOBase | Build and register the required OpenCV, VXL, or file-list factory before automatic IO selection. |
| A temporal filter receives fewer frames than its declared stencil | The filter rejects the request or cannot form the requested output frame | Keep unit input duration and frame offset aligned with the filter's temporal operation. |
| A compressed backend seeks beyond its last safe key frame | A random frame request can fail or produce an unexpected decode position | Use the reader's safe-frame behavior and treat backend key-frame limits as part of the source contract. |
| A frame has an unsupported dimension, channel count, or component type | Reader, bridge, or writer conversion fails | Match the VideoStream frame type and backend format limits before running the pipeline. |
| A source request contains frames with different spatial sizes | Spatial work can be split from the leading frame's region and may not fit every frame | Keep spatial regions compatible within a request or use a filter that handles per-frame regions explicitly. |
| A file list has incompatible names or no usable image IO | The list is not selected or a frame cannot be opened | Use one compatible extension and ensure the image IO factory supports the frame files. |
| Writer frame rate or FourCC is missing | The writer refuses to start | Set timing and codec parameters before writing. |
| OpenCV requests real-time position from an ITK stream | The capture bridge raises an unsupported-operation error | Use frame-based positions with the current OpenCVVideoCapture bridge. |
| An OpenCV or VXL factory is not registered | Automatic selection cannot find that backend even when its library is built | Register the factory or pass a suitable VideoIOBase explicitly. |
| OpenCV cannot be found when the bridge is loaded by a consuming application | The OpenCV bridge cannot be configured or linked for that application | Keep the bridge's build and install export settings aligned with the OpenCV package and platform options. |
OpenCV opens a file or device through OpenCVVideoCapture | The bridge throws instead of providing ordinary capture | Use cv::VideoCapture for external files and devices; use OpenCVVideoCapture only for an ITK VideoStream. |
| VXL is asked to read from a camera | The backend cannot provide camera input | Select a backend with camera support, such as OpenCV. |
| A wrapped image input uses the lowest configured image dimension | No matching ImageToVideoFilter wrapper is generated for that input form | Use an input dimension that produces a supported VideoStream frame dimension. |
Key files
| File | Why to read it |
|---|---|
| Modules/…/itkTemporalDataObject.h | Defines temporal regions, buffered temporal data, and frame or real-time units. |
| Modules/…/itkTemporalProcessObject.h | Defines how temporal requests become input stencils and output operations. |
| Modules/…/itkVideoStream.h | Defines the frame sequence model, frame buffering, and per-frame spatial metadata. |
Modules/Video/Core/include/itkVideoSource.hxx | Defines source output preparation, frame allocation, and spatial work splitting. |
| Modules/…/itkVideoToVideoFilter.h | Defines the common video filter connection and spatial request propagation. |
| Modules/…/itkImageToVideoFilter.h | Shows how an image axis becomes the temporal axis of a video stream. |
Modules/Video/Core/wrapping/itkImageToVideoFilter.wrap | Shows which image dimensions and scalar or vector forms are exposed to wrapped users. |
| Modules/…/itkVideoIOBase.h | Defines the backend-neutral read, camera, seek, timing, and write contract. |
| Modules/…/itkVideoFileReader.h | Shows how external video becomes a streamed VideoStream. |
| Modules/…/itkVideoFileWriter.h | Shows how a requested video range becomes external output. |
| Modules/…/itkVideoIOFactory.h | Shows how registered backends are selected for files and cameras. |
| Modules/…/itkFileListVideoIO.h | Describes the image-file-list representation of a video. |
| Modules/…/itkFrameAverageVideoFilter.h | Illustrates a multi-frame temporal reduction. |
| Modules/…/itkFrameDifferenceVideoFilter.h | Illustrates a frame-offset comparison. |
| Modules/…/itkDecimateFramesVideoFilter.h | Illustrates temporal down-sampling by frame selection. |
| Modules/…/itkImageFilterToVideoFilterWrapper.h | Shows how an image filter runs inside a video pipeline. |
| Modules/…/CMakeLists.txt | Shows how the OpenCV bridge exposes its external dependency to build and installed consumers. |
| Modules/…/itkOpenCVVideoIO.h | Defines the OpenCV file and camera backend boundary. |
| Modules/…/itkOpenCVVideoIOFactory.h | Shows how the OpenCV backend enters automatic video IO selection. |
| Modules/…/itkOpenCVVideoCapture.h | Defines the OpenCV view of an ITK-produced video stream. |
| Modules/…/itkOpenCVImageBridge.h | Defines image and channel conversion between ITK and OpenCV. |
| Modules/…/itkVXLVideoIO.h | Defines the VXL and FFmpeg backend boundary. |
| Modules/…/itkVXLVideoIOFactory.h | Shows how the VXL backend enters automatic video IO selection. |