# Getting a scalar value by checking vtkColorTransferFunction RGB color

**URL:** https://discourse.vtk.org/t/getting-a-scalar-value-by-checking-vtkcolortransferfunction-rgb-color/3571
**Category:** Support
**Created:** [June 16, 2020, 3:02pm UTC](https://discourse.vtk.org/t/getting-a-scalar-value-by-checking-vtkcolortransferfunction-rgb-color/3571 "2020-06-16T15:02:01Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![lonewolf](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/l/3da27b/32.png) [@lonewolf](https://discourse.vtk.org/u/lonewolf)
#### Post date: [June 16, 2020, 3:02pm UTC](https://discourse.vtk.org/t/getting-a-scalar-value-by-checking-vtkcolortransferfunction-rgb-color/3571/1 "2020-06-16T15:02:01Z")

</div>

Hi all,  
I have been using VTK for some years now but a new challenge popped up.  
I need to reverse engineer the function

void vtkColorTransferFunction::GetTable( double xStart, double xEnd, int size, double\* table )

into getting a Value at a given RGB color.

While the GetTable function can be passed a xStart = xEnd to obtain just one color for a given Scalar value, I need to do the opposite. Given a RGB color, getting the scalar that maps to it.

Is there already any function around that I am not finding? Or do I have to write that function by extending the class?

Best regards!

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [June 16, 2020, 3:35pm UTC](https://discourse.vtk.org/t/getting-a-scalar-value-by-checking-vtkcolortransferfunction-rgb-color/3571/2 "2020-06-16T15:35:01Z")

</div>

Inverse lookup is not implemented as it is normally should not be necessary and a general solution would not be trivial (for example, the same RGB value can be mapped to many scalar values). So, if you really need this, then you need to implement it.

---

<div class="post-metadata">

### Author: ![wulicheng](https://discourse.vtk.org/user_avatar/discourse.vtk.org/wulicheng/32/1990_2.png) [@wulicheng](https://discourse.vtk.org/u/wulicheng)
#### Post date: [June 17, 2020, 6:45am UTC](https://discourse.vtk.org/t/getting-a-scalar-value-by-checking-vtkcolortransferfunction-rgb-color/3571/3 "2020-06-17T06:45:53Z")

</div>

> [@lonewolf](#):
>
> Is there already any function around that I am not finding? Or do I have to write that function by extending the class?
> 
> Best regards!

luminance = 0.3_R + 0.59_G + 0.11\*B  
the same RGB just can be mapped one scalar values,I think!

---

<div class="post-metadata">

### Author: ![lonewolf](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/l/3da27b/32.png) [@lonewolf](https://discourse.vtk.org/u/lonewolf)
#### Post date: [June 17, 2020, 8:40am UTC](https://discourse.vtk.org/t/getting-a-scalar-value-by-checking-vtkcolortransferfunction-rgb-color/3571/4 "2020-06-17T08:40:51Z")

</div>

Hi! Thank you for your answers!  
Andras, That’s what I recon. An alternative would be to replace the lookup for a linear gray scale lookup mapped to the Scalar range. Then the gray value would immediately tell me what the scalar value is. Would you agree with this?

wulicheng, could you explain further?

lonewolf

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [July 11, 2020, 11:35pm UTC](https://discourse.vtk.org/t/getting-a-scalar-value-by-checking-vtkcolortransferfunction-rgb-color/3571/5 "2020-07-11T23:35:23Z")

</div>

What would you like to achieve? If you want to determine point ID or coordinates then you can use VTK’s picker classes.
