# Voxel wise multiplication of vector images and vector constants

**URL:** https://discourse.itk.org/t/voxel-wise-multiplication-of-vector-images-and-vector-constants/1426
**Category:** Engineering
**Created:** [November 19, 2018, 2:47pm UTC](https://discourse.itk.org/t/voxel-wise-multiplication-of-vector-images-and-vector-constants/1426 "2018-11-19T14:47:53Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![gdevenyi](https://discourse.itk.org/user_avatar/discourse.itk.org/gdevenyi/32/355_2.png) [@gdevenyi](https://discourse.itk.org/u/gdevenyi)
#### Post date: [November 19, 2018, 2:47pm UTC](https://discourse.itk.org/t/voxel-wise-multiplication-of-vector-images-and-vector-constants/1426/1 "2018-11-19T14:47:53Z")

</div>

I’m working on cleaning up the MINC support (IO and Transforms) in ITK, and my last step is to properly handle the MINC non-linear deformation files. The major change is to convert the coordinate system every single voxel vector element from RAS to LPS, equivalent to multiplication with (-1,-1,0). See [https://github.com/InsightSoftwareConsortium/ITK/pull/147](https://github.com/InsightSoftwareConsortium/ITK/pull/147)

From my reading, [https://itk.org/Doxygen/html/classitk\_1\_1MultiplyImageFilter.html](https://itk.org/Doxygen/html/classitk_1_1MultiplyImageFilter.html) doesn’t seem to support templating (is that the right term?) over a vector, only images, or constants.

So the question arises, do I write some special code for the TransforMINC module, or do I make some modifications to the MultiplyImageFilter. Would there be other users of such functionality?

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [November 19, 2018, 3:27pm UTC](https://discourse.itk.org/t/voxel-wise-multiplication-of-vector-images-and-vector-constants/1426/2 "2018-11-19T15:27:29Z")

</div>

I would just use the unary functor generator filter with a lambda expression.

I can post more details if you need them when I’m available.

Brad

---

<div class="post-metadata">

### Author: ![gdevenyi](https://discourse.itk.org/user_avatar/discourse.itk.org/gdevenyi/32/355_2.png) [@gdevenyi](https://discourse.itk.org/u/gdevenyi)
#### Post date: [November 19, 2018, 4:13pm UTC](https://discourse.itk.org/t/voxel-wise-multiplication-of-vector-images-and-vector-constants/1426/3 "2018-11-19T16:13:24Z")

</div>

This filter does indeed look like what I want to do.

I’ll take a look at the examples and see if I can successfully copy the methods and apply it.

I’ll follow up if I have any questions.

---

<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: [November 19, 2018, 4:44pm UTC](https://discourse.itk.org/t/voxel-wise-multiplication-of-vector-images-and-vector-constants/1426/4 "2018-11-19T16:44:44Z")

</div>

Depending on the implementation, directly [using `itk::MultiThreaderBase::ParallelizeImageRegion`](https://itk.org/ITKExamples/src/Core/Common/UseParallelizeImageRegion/Documentation.html) may be preferred to avoid the filter call.

---

<div class="post-metadata">

### Author: ![gdevenyi](https://discourse.itk.org/user_avatar/discourse.itk.org/gdevenyi/32/355_2.png) [@gdevenyi](https://discourse.itk.org/u/gdevenyi)
#### Post date: [November 26, 2018, 8:17pm UTC](https://discourse.itk.org/t/voxel-wise-multiplication-of-vector-images-and-vector-constants/1426/5 "2018-11-26T20:17:54Z")

</div>

Thanks @matt.mccormick

I went the ParallelizeImageRegion route and now have an addition to my patch at [https://github.com/InsightSoftwareConsortium/ITK/pull/147](https://github.com/InsightSoftwareConsortium/ITK/pull/147)
