# about vtk SMP

**URL:** <https://discourse.vtk.org/t/about-vtk-smp/11941>\
**Category:** Development\
**Tags:** code\
**Created:** [July 13, 2023, 9:33am UTC](https://discourse.vtk.org/t/about-vtk-smp/11941 "2023-07-13T09:33:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marlon.ma](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marlon.ma/32/6091_2.png) [@marlon.ma](https://discourse.vtk.org/u/marlon.ma)\
**Post date:** [July 13, 2023, 9:33am UTC](https://discourse.vtk.org/t/about-vtk-smp/11941/1 "2023-07-13T09:33:18Z")

</div>

```auto
ImageMapToColors = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
	ImageMapToColors->SetWindow(Window);
	ImageMapToColors->SetLevel(level);
	ImageMapToColors->SetInputData(ImageData);
	ImageMapToColors->SetEnableSMP(1);
	ImageMapToColors->SetNumberOfThreads(16);
	ImageMapToColors->Update();

```

Why can’t I speed up this process by using SetEnableSMP?

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [July 13, 2023, 3:13pm UTC](https://discourse.vtk.org/t/about-vtk-smp/11941/2 "2023-07-13T15:13:29Z")

</div>

Like most of the VTK image filters, this filter is multithreaded by default. It will automatically use the fastest threading method available. So I recommend to _not_ call `SetEnableSMP()` or `SetNumberOfThreads()`.

Perhaps `vtkImageMapToColors` will be faster, since its code is less complex. The usage is slightly different:

```cpp
LUT = vtkSmartPointer<vtkScalarsToColors>::New();
LUT.SetRange(Level - 0.5*Window, Level + 0.5*Window);

ImageMapToColors = vtkSmartPointer<vtkImageMapToColors>::New();
ImageMapToColors->SetLookupTable(LUT);
ImageMapToColors->SetInputData(ImageData);

```

Also, it’s possible your code is calling this filter in an inefficient manner, for example if you are only displaying one slice, but you are calling ImageMapToColors on the entire volume, that will greatly reduce the speed.

---

<div class="post-metadata">

**Author:** ![marlon.ma](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marlon.ma/32/6091_2.png) [@marlon.ma](https://discourse.vtk.org/u/marlon.ma)\
**Post date:** [July 14, 2023, 1:01am UTC](https://discourse.vtk.org/t/about-vtk-smp/11941/3 "2023-07-14T01:01:48Z")

</div>

ok I understand
