# Logarithmic Color scale Bar

**URL:** <https://discourse.slicer.org/t/logarithmic-color-scale-bar/20656>\
**Category:** Support\
**Created:** [November 17, 2021, 12:20pm UTC](https://discourse.slicer.org/t/logarithmic-color-scale-bar/20656 "2021-11-17T12:20:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MathiasBrucker](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@MathiasBrucker](https://discourse.slicer.org/u/MathiasBrucker)\
**Post date:** [November 17, 2021, 12:20pm UTC](https://discourse.slicer.org/t/logarithmic-color-scale-bar/20656/1 "2021-11-17T12:20:52Z")

</div>

Slicer version: 4.11.202  
Operating system: Windows 10 x64  
Software: Jupyter Notebook with Slicer Kernel 4.11

Is it possible to generate a Color Scale Bar with Logarithmic Values.  
Since I am working with low distances in the modeltomodeldistance, a logarithmic color scale is needed. With the vtkMRMLProceduralColorNode i can log the LUT colors and the labels are all with the same distances as seen in this picture below.

 ![LogarithmicColors](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/2/a20bf8d7204a37db7af2b0b0dc1cb8d763952980.png)  
My question is now to switch the bar and the labels, so the label are logarithmic with low values have a bigger range than higher labels and the color bar with the lut stays in normal range. I tried it with the ProceduralNode and also had a look with at the ColorTableNode but couldn’t figure out how to deal with my problem.  
Thanks in advance for dealing with my problem and I am thankful for all the input of the community  
Mathias Brucker

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 17, 2021, 5:57pm UTC](https://discourse.slicer.org/t/logarithmic-color-scale-bar/20656/2 "2021-11-17T17:57:19Z")

</div>

@Mik you have been doing a great job in reworking the color bar display. Can you comment on feasibility of logarirthmic scale? Is log scal already supported by the scalar bar widget?

---

<div class="post-metadata">

**Author:** ![Mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@Mik](https://discourse.slicer.org/u/Mik)\
**Post date:** [November 17, 2021, 6:44pm UTC](https://discourse.slicer.org/t/logarithmic-color-scale-bar/20656/3 "2021-11-17T18:44:39Z")

</div>

I have not tested it with logarithmic scale it yet. The [ScalarBar](https://vtk.org/doc/nightly/html/classvtkScalarBarActor.html) manual says that if vtkLookupTable has a logarithmic scale then the labels are created using a logarithmic scale.

Anyway it shouldn’t be to difficult to add a check box and flag to the node to switch between log and linear scale.

@MathiasBrucker You can try to set [log scale](https://vtk.org/doc/nightly/html/classvtkLookupTable.html#a93a46edc6ca10b0ba0e7cfff4acb52e9) to the LUT instead of linear scale.

Do you have any king of test data so i can check the log scale support?

---

<div class="post-metadata">

**Author:** ![Mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@Mik](https://discourse.slicer.org/u/Mik)\
**Post date:** [November 20, 2021, 7:28am UTC](https://discourse.slicer.org/t/logarithmic-color-scale-bar/20656/4 "2021-11-20T07:28:25Z")

</div>

Here what i have got with logarithmic scale  
Test LUT

```auto
colorTableNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLProceduralColorNode", "TestLogColors")
colorTableNode.SetType(slicer.vtkMRMLColorTableNode.User)
colorTransferFunction = vtk.vtkDiscretizableColorTransferFunction()
colorTransferFunction.AddRGBPoint(0.01, 1.0, 0.0, 0.0)
colorTransferFunction.AddRGBPoint(0.1, 0.0, 1.0, 0.0)
colorTransferFunction.AddRGBPoint(1.0, 0.3, 0.0, 1.0)
colorTransferFunction.AddRGBPoint(10.0, 0.6, 0.0, 1.0)
colorTransferFunction.AddRGBPoint(100.0, 0.6, 0.6, 1.0)
colorTransferFunction.AddRGBPoint(1000.0, 1., 1., 1.0)
colorTableNode.SetAndObserveColorTransferFunction(colorTransferFunction) 

```

LUT screenshot:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/8/786e27609aceacfa0970a15f3f368e721f40910b.jpeg)

ColorBarDisplayNode parameters screenshot:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/2/32f7245e9f67b43478eab44169e2d8696217647a.jpeg)

Unfortunately it still doesn’t work quiet well with Models (the program crashes if the model has already been visible).

---

<div class="post-metadata">

**Author:** ![MathiasBrucker](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@MathiasBrucker](https://discourse.slicer.org/u/MathiasBrucker)\
**Post date:** [November 22, 2021, 11:40am UTC](https://discourse.slicer.org/t/logarithmic-color-scale-bar/20656/5 "2021-11-22T11:40:05Z")

</div>

Thanks @Mik for your reply, I couldn’t test it yet but i will try it with the logarithmic LUT on the color Node.
