[vtkusers] convert a float image into 16bit grayscale
David Doria
daviddoria at gmail.com
Wed Nov 23 11:25:05 EST 2011
On Wed, Nov 23, 2011 at 11:18 AM, ankit master <ankit.master at gmail.com> wrote:
> Hello,
>
> I have a 256x 256 image of float values and I am trying to visualize it into
> 16bit Grayscale format. I tried using a lookup table but everytime i either
> get a blue image or a red image but not a grayscale image. Any help is
> greatly appreciated
>
> vtkSmartPointer<vtkLookupTable> lut=
> vtkSmartPointer<vtkLookupTable>::New();
> lut->SetTableRange(0,65535);
> lut->SetNumberOfTableValues(65536);
> lut->SetHueRange(0,0);
> lut->SetValueRange(0, 1);
> lut->Build();
> for(int i=0; i<65536; i++)
> {
> float val1 = (float)i/65536 ;
> lut->SetTableValue(i, val1, val1,val1);
> }
>
>
>
> vtkActor *actor1 = vtkActor::New();
> vtkPolyDataMapper *mapper1 = vtkPolyDataMapper::New();
> vtkImageDataGeometryFilter *convertToPolyImageFilter =
> vtkImageDataGeometryFilter::New();
> convertToPolyImageFilter->SetInput(connector->GetOutput() );
> convertToPolyImageFilter->Update();
> mapper1->SetInput(convertToPolyImageFilter->GetOutput() );
> Thank you
> Ankit
Why are you using a vtkPolyDataMapper + vtkActor to display an image?
You should consider vtkImageSlice + vtkImageSliceMapper instead:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/ImageSliceMapper
David
More information about the vtkusers
mailing list