How to get color of pixel(or position) on colored polydata

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get color of pixel(or position) on colored polydata

Tharun
This post was updated on .
I would like to know the color of any position on actor created below.

vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInput(polydata);
mapper->UseLookupTableScalarRangeOn();
mapper->InterpolateScalarsBeforeMappingOn();
mapper->SetLookupTable(lookUpTable);
mapper->ImmediateModeRenderingOn();

vtkSmartPointer<PSVTKLODActor> actor = vtkSmartPointer<PSVTKLODActor>::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetInterpolationToFlat();

Thank you
Reply | Threaded
Open this post in threaded view
|

Re: How to get color of pixel(or position) on colored polydata

Cory Quammen-2
This example may help:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/Picking

On Tue, Apr 25, 2017 at 5:42 AM, Tharun <[hidden email]> wrote:

> I would like to know the color of pixel or position on actor created below.
>
> vtkSmartPointer<vtkPolyDataMapper> mapper =
> vtkSmartPointer<vtkPolyDataMapper>::New();
> mapper->SetInput(polydata);
> mapper->UseLookupTableScalarRangeOn();
> mapper->InterpolateScalarsBeforeMappingOn();
> mapper->SetLookupTable(lookUpTable);
> mapper->ImmediateModeRenderingOn();
>
> vtkSmartPointer<PSVTKLODActor> actor =
> vtkSmartPointer<PSVTKLODActor>::New();
> actor->SetMapper(mapper);
> actor->GetProperty()->SetInterpolationToFlat();
>
> Thank you
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/How-to-get-color-of-pixel-or-position-on-colored-polydata-tp5742972.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers



--
Cory Quammen
Staff R&D Engineer
Kitware, Inc.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: How to get color of pixel(or position) on colored polydata

Tharun
Thank you for the heads up.

I do know how to pick a position. But, i want to know the value of color at a particular position. My actor consists of triangles and I can find triangle picked. My current workflow is

1) Find triangle picked
2) Find Barycentric coordinates of position picked in the triangle.
3) Interpolate color of position from the colors of vertices of triangle using Barycentric coordinates.

But, the color calculate is wrong at times.

I found that, in the actor I created, color inside triangle is interpolated per pixel basis. But, I have no idea how is that done.
Reply | Threaded
Open this post in threaded view
|

Re: How to get color of pixel(or position) on colored polydata

Cory Quammen-2
That sounds fairly complicated to get the color. Do you just want the
color of the pixel at the location in the image? If so, you should be
able to use vtkRenderWindow::GetPixelData():

http://www.vtk.org/doc/nightly/html/classvtkWindow.html#afe513c0f9e8eaaf76d924cc9ce99182b

On Tue, Apr 25, 2017 at 9:18 PM, Tharun <[hidden email]> wrote:

> Thank you for the heads up.
>
> I do know how to pick a position. But, i want to know the value of color at
> a particular position. My actor consists of triangles and I can find
> triangle picked. My current workflow is
>
> 1) Find triangle picked
> 2) Find Barycentric coordinates of position picked in the triangle.
> 3) Interpolate color of position from the colors of vertices of triangle
> using Barycentric coordinates.
>
> But, the color calculate is wrong at times.
>
> I found that, in the actor I created, color inside triangle is interpolated
> per pixel basis. But, I have no idea how is that done.
>
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/How-to-get-color-of-pixel-or-position-on-colored-polydata-tp5742972p5742982.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers



--
Cory Quammen
Staff R&D Engineer
Kitware, Inc.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: How to get color of pixel(or position) on colored polydata

Tharun
This has solved my problem.

Thank you very much.