# vtkOBJImporter load data, and how to get the color of point, and change some of the cells' color by SetScalars?

**URL:** https://discourse.vtk.org/t/vtkobjimporter-load-data-and-how-to-get-the-color-of-point-and-change-some-of-the-cells-color-by-setscalars/12891
**Category:** Support
**Tags:** python, code
**Created:** [December 13, 2023, 7:44am UTC](https://discourse.vtk.org/t/vtkobjimporter-load-data-and-how-to-get-the-color-of-point-and-change-some-of-the-cells-color-by-setscalars/12891 "2023-12-13T07:44:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![yangyang117](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/y/da6949/32.png) [@yangyang117](https://discourse.vtk.org/u/yangyang117)
#### Post date: [December 13, 2023, 7:44am UTC](https://discourse.vtk.org/t/vtkobjimporter-load-data-and-how-to-get-the-color-of-point-and-change-some-of-the-cells-color-by-setscalars/12891/1 "2023-12-13T07:44:48Z")

</div>

Hi, When I use vtkOBJImporter load some obj mtl file, I can get the mapper, actor, and polydata of the data, But I want to get the color of point in polydata by texture data.

Issue1: I found some ways to get the rgb value of texture map, but I cannot get the texture map of the mtl file.  
Issue2:I want to change some cell’s color by id, like the geomatic(when choose some area, the cells of this area will be dark red ), I trid to use SetScalars of the polydata, but it does not work.

---

<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: [December 15, 2023, 2:59pm UTC](https://discourse.vtk.org/t/vtkobjimporter-load-data-and-how-to-get-the-color-of-point-and-change-some-of-the-cells-color-by-setscalars/12891/2 "2023-12-15T14:59:30Z")

</div>

1. You can use vtkProbeFilter to get texture value at a position. See a complete example in the TextureModel module in a 3D Slicer extension:

> <https://github.com/SlicerIGT/SlicerIGT/blob/20ff7abdb7fd0126f353337d3c90aed323f8b9eb/TextureModel/TextureModel.py#L160-L243>

1. Once you switched to color by point data, you can change color by changing that point data array. If you want to have sharp edges then you need to switch from using point data to cell data.

---

<div class="post-metadata">

### Author: ![yangyang117](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/y/da6949/32.png) [@yangyang117](https://discourse.vtk.org/u/yangyang117)
#### Post date: [December 16, 2023, 2:58am UTC](https://discourse.vtk.org/t/vtkobjimporter-load-data-and-how-to-get-the-color-of-point-and-change-some-of-the-cells-color-by-setscalars/12891/3 "2023-12-16T02:58:48Z")

</div>

Thanks. The solution looks well. I soulve this problems by reading the orgiginal obj file and png picture.  
Because the actor by objimport is opengl actor, it can not be deepcopy(Beacause in my task, I need to segment the data to 2 or more parts), so I prefer to load obj file and make an normal polydata, and show the color by polydata.GetCellData().SetScalars() and vlookuptable. It seems well and more editable.  
anyway thank you very much.

---

<div class="post-metadata">

### Author: ![yangyang117](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/y/da6949/32.png) [@yangyang117](https://discourse.vtk.org/u/yangyang117)
#### Post date: [January 8, 2024, 9:06am UTC](https://discourse.vtk.org/t/vtkobjimporter-load-data-and-how-to-get-the-color-of-point-and-change-some-of-the-cells-color-by-setscalars/12891/4 "2024-01-08T09:06:37Z")

</div>

Hi, Andras, I’m using vtk to get the threshold segment and translate it to polydata. But here is some problems, Can you see it? Thank you.  
If possible, Can you give me how slicer process this flow?(Get the CT, threshold, translate to polydata?)

here is the link:

> [@Use threshold for the CT Segment and translate the labelmap to polydata](https://discourse.vtk.org/t/use-threshold-for-the-ct-segment-and-translate-the-labelmap-to-polydata/13028):
>
> Hi, I’m using threshold for a CT’s bone surface, and using vtkDiscreteMarchingCubes to get the first polydata,but the data is too large,when I use vtkQuadricDecimation to reduce the number of cells, but there will have some holes and non manifold edges. I have no idea how to solve the problem. ① should I smooth the CT before the threshold? ② how to reduce the number of cells without the holes or non manifold edges appear? ③ Is there parameters that I should set when using the vtkDiscreteMarc…
