# How to change volume'color ?

**URL:** https://discourse.vtk.org/t/how-to-change-volumecolor/2061
**Category:** Development
**Tags:** proposal
**Created:** [November 7, 2019, 7:41am UTC](https://discourse.vtk.org/t/how-to-change-volumecolor/2061 "2019-11-07T07:41:41Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Lee](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/l/bc8723/32.png) [@Lee](https://discourse.vtk.org/u/Lee)
#### Post date: [November 7, 2019, 7:41am UTC](https://discourse.vtk.org/t/how-to-change-volumecolor/2061/1 "2019-11-07T07:41:41Z")

</div>

I use ParaView to import RAW file, Its results are as follows：

 ![2019-11-07%2015-38-17%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE](https://discourse.vtk.org/uploads/default/original/2X/9/93a7856e93b7f99ea5d6ae929d303df0e73a9f17.png)  
I want to use VTK to simuate this result, Its results are as follows： ![2019-11-07%2015-36-27%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE](https://discourse.vtk.org/uploads/default/original/2X/a/a18460f606b7bebe6ce834a4d4bf4e58d11ee46e.png)

and i want to change my result’s color ,how to change volume’color ?

---

<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: [November 7, 2019, 1:52pm UTC](https://discourse.vtk.org/t/how-to-change-volumecolor/2061/2 "2019-11-07T13:52:51Z")

</div>

There may be some Paraview users here who could answer your question, but this topic would be more appropriate for [ParaView forum](https://discourse.paraview.org/).

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cory.quammen/32/6751_2.png) [@cory.quammen](https://discourse.vtk.org/u/cory.quammen)
#### Post date: [November 7, 2019, 2:15pm UTC](https://discourse.vtk.org/t/how-to-change-volumecolor/2061/3 "2019-11-07T14:15:52Z")

</div>

@Lee wants to know how to replicated ParaView’s volume rendering result in VTK, so it is appropriate for this forum.

You’ll need to set the color transfer function and opacity function to match what is in ParaView. Here is an example of how to set up such functions: [https://lorensen.github.io/VTKExamples/site/Cxx/VolumeRendering/SimpleRayCast/](https://lorensen.github.io/VTKExamples/site/Cxx/VolumeRendering/SimpleRayCast/).

Then, you’ll need to translate the transfer function settings from ParaView to code like in the example. Look at the values in the color table and opacity table in the _Color Map Editor_ in ParaView (these are advanced settings, so click the gear icon to show them). Here’s a screenshot showing what I mean:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/4/4ca0f79caec2cb3bc2cc9952ae01b1ba090ac529.png)

The gear button is on the right side near the middle of the image, and the values and colors are shown in the tables below that. Note that the color space is important.

Good luck!

---

<div class="post-metadata">

### Author: ![Lee](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/l/bc8723/32.png) [@Lee](https://discourse.vtk.org/u/Lee)
#### Post date: [November 15, 2019, 6:00am UTC](https://discourse.vtk.org/t/how-to-change-volumecolor/2061/4 "2019-11-15T06:00:11Z")

</div>

Thank you for your reply！  
According to your advice, my problem has been solved.

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cory.quammen/32/6751_2.png) [@cory.quammen](https://discourse.vtk.org/u/cory.quammen)
#### Post date: [November 15, 2019, 3:37pm UTC](https://discourse.vtk.org/t/how-to-change-volumecolor/2061/5 "2019-11-15T15:37:37Z")

</div>

Great, thanks for following up to let us know!

---

<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: [May 11, 2020, 6:40am UTC](https://discourse.vtk.org/t/how-to-change-volumecolor/2061/6 "2020-05-11T06:40:32Z")

</div>

CTK maybe a good solution. As This question I have encountered.

---

<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: [May 11, 2020, 6:43am UTC](https://discourse.vtk.org/t/how-to-change-volumecolor/2061/7 "2020-05-11T06:43:29Z")

</div>

> [@How can i integrate the QWidget and the vtkContextView?](https://discourse.vtk.org/t/how-can-i-integrate-the-qwidget-and-the-vtkcontextview/2895):
>
> How can i integrate the vtkContextView withe the Qt’widget like QVTKＷＩｇｅｔ?

Andras Lasso have give me a good solution
