# Import multiple images using vtkImageImport

**URL:** https://discourse.vtk.org/t/import-multiple-images-using-vtkimageimport/1991
**Category:** Support
**Created:** [October 28, 2019, 5:53am UTC](https://discourse.vtk.org/t/import-multiple-images-using-vtkimageimport/1991 "2019-10-28T05:53:25Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![Yongun\_Lee](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/y/6f9a4e/32.png) [@Yongun\_Lee](https://discourse.vtk.org/u/Yongun_Lee)
#### Post date: [November 4, 2019, 1:29am UTC](https://discourse.vtk.org/t/import-multiple-images-using-vtkimageimport/1991/7 "2019-11-04T01:29:16Z")

</div>

> [@dgobbi](#):
>
> > Blend mode (min / max / mean).
> 
> I don’t understand, can you explain what you mean?

I referenced the term in the vtkImageSlabReslice::SetBlendMode(int) function.  
I think this means MinIP / MIP / Average.

> Sorry. It seems to be my mistake  
> The problem was that I used it as a negative number.  
> Using positive numbers works fine. (Is it correct to use absolute values even if the result is negative?)

* * *

> [@dgobbi](#):
>
> > I averaged the ‘s’ distance for each slice and used that value.
> 
> Do you mean the Δs value, the distance from each slice to its neighbor? If so, then that is the correct value to use for the spacing.

My English is not good enough, so I’m not sure if you and I are saying the same thing.  
Attach my sample code

```
double s, total, avg;
for (int i = 0; i < 20; i++) // There are 20 slices in total.
{
    
    if (i > 0)
    {
        total += abs(slice[i].dot() - s) // Sum the distance between neighboring slices.
    }

    s = slice[i].dot(); // Signed Distance along Slice Plane Normal
}

avg = total / 19; // use this value

vtkSmartPointer<vtkImageImport> importer = vtkSmartPointer<vtkImageImport>::New();
importer->SetDataSpacing(PixelSpacing[0], PixelSpacing[1], avg);
importer->SetDataOrigin(0, 0, 0);
importer->SetWholeExtent(0, nWidth - 1, 0, nHeight - 1, 0, nCount - 1);
importer->SetDataExtentToWholeExtent();

```

---

_[View the full topic](https://discourse.vtk.org/t/import-multiple-images-using-vtkimageimport/1991)._
