[vtkusers] Vector Field From Image Glyph3d
Andaharoo
Andx_roo at live.com
Fri Sep 7 19:05:36 EDT 2018
I'm trying to use the glyph3d filter to make a vector field from a 3
component image. Let's call the components r, g, and b. I want r to
correspond with x, g with y, and b with z. Unfortunately I cannot figure out
how to do this with glyph3d after looking at all the examples and an hour of
googling.
It seems like it was meant to do this but all the settings make it too
confusing. Currently it appears as though it only considers the first
component for the direction and x and -x directions are the only ways the
arrows will point. (see image)
<http://vtk.1045678.n5.nabble.com/file/t342007/2018-09-07_17_59_27-Visualization_Toolkit_-_Win32OpenGL_%231.png>
In this test image you can see the arrows won't point up in green (y). They
just disappear?
vtkSmartPointer<vtkPNGReader> reader = vtkSmartPointer<vtkPNGReader>::New();
reader->SetFileName("testing.png");
reader->Update();
// Shift and ccast to have a float image -127.5 to 127.5 for negative
direction
vtkSmartPointer<vtkImageShiftScale> shiftScale =
vtkSmartPointer<vtkImageShiftScale>::New();
shiftScale->SetInputData(reader->GetOutput());
shiftScale->SetOutputScalarTypeToFloat();
shiftScale->SetShift(-127.5);
shiftScale->Update();
vtkSmartPointer<vtkArrowSource> glyphSource =
vtkSmartPointer<vtkArrowSource>::New();
glyphSource->Update();
vtkSmartPointer<vtkGlyph3D> glyphFilter =
vtkSmartPointer<vtkGlyph3D>::New();
glyphFilter->SetSourceConnection(glyphSource->GetOutputPort());
glyphFilter->SetScaleFactor(0.006); // Scale a bit because arrows are far
too big
glyphFilter->SetInputData(shiftScale->GetOutput());
glyphFilter->Update();
--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
More information about the vtkusers
mailing list