# VectorImageToImageMetricTraitsv4 with VectorImage - dynamic number of components

**URL:** https://discourse.itk.org/t/vectorimagetoimagemetrictraitsv4-with-vectorimage-dynamic-number-of-components/4980
**Category:** Beginner Questions
**Tags:** registration
**Created:** [May 12, 2022, 2:02am UTC](https://discourse.itk.org/t/vectorimagetoimagemetrictraitsv4-with-vectorimage-dynamic-number-of-components/4980 "2022-05-12T02:02:26Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![zbjornson](https://discourse.itk.org/user_avatar/discourse.itk.org/zbjornson/32/2667_2.png) [@zbjornson](https://discourse.itk.org/u/zbjornson)
#### Post date: [May 12, 2022, 2:02am UTC](https://discourse.itk.org/t/vectorimagetoimagemetrictraitsv4-with-vectorimage-dynamic-number-of-components/4980/1 "2022-05-12T02:02:26Z")

</div>

Hello,

The intro text to [Perform Registration on Vector Images — v5.3.0](https://examples.itk.org/src/registration/metricsv4/performregistrationonvectorimages/documentation) suggests that that code can be used with a `VectorImage`. It uses `VectorImageToImageMetricTraitsv4`, and the docs for that class say it works with `VectorImage`. However, it takes `VNumberOfComponents` as a template parameter, while `VectorImage` can have a dynamic number of components.

Is there any way to do registration of vector images with a dynamic number of components, or must it be determined at compile-time?

Thanks,  
Zach

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [May 13, 2022, 9:43am UTC](https://discourse.itk.org/t/vectorimagetoimagemetrictraitsv4-with-vectorimage-dynamic-number-of-components/4980/2 "2022-05-13T09:43:29Z")

</div>

Hello Zach!

Welcome to the ITK community ! 🌞

> [@zbjornson](#):
>
> Is there any way to do registration of vector images with a dynamic number of components, or must it be determined at compile-time?

To test this, a `VariableLengthVectorImageToImageMetricTraitsv4` could be created. It looks like `VectorImageToImageMetricTraitsv4` uses the `NumberOfComponent` to define the type for the gradients used by the metric. This would need to be changed to `VectorImage` to be dynamic.
