[vtkusers] creating vtkImageData from byte[] - Java
Amey
amay.ms at gmail.com
Wed Jan 7 12:13:41 EST 2015
Hello,
I have a image data in byte[] which I am converting into vtkImageData as
following:
byte[] tileData = reader.getImageData(...);
vtkUnsignedCharArray array = new vtkUnsignedCharArray();
array.SetJavaArray( tileData );
array.SetName( "scalars" );
vtkImageData imgData = new vtkImageData();
imgData.SetDimensions( reader.getWidth(),
reader.getHeight(), 1 );
imgData.SetOrigin( 0, 0, 0 );
imgData.SetSpacing( 1.0, 1.0, 1.0 );
imgData.GetPointData().SetScalars( array );
vtkImageFlip imgFlip = new vtkImageFlip();
imgFlip.SetInputData( imgData );
imgFlip.SetFilteredAxis( 1 );
vtkImageMapper imgMapper = new vtkImageMapper();
imgMapper.SetInputConnection( imgFlip.GetOutputPort() );
imgMapper.SetColorWindow( 255.0 );
imgMapper.SetColorLevel( 127.5 );
vtkActor2D actor = new vtkActor2D();
actor.SetMapper( imgMapper );
...
When I render the actor, the image is displayed gray scale, but my data is
24 bit full colored image.
Any clue what is missing here?
Thank you for your help.
--
View this message in context: http://vtk.1045678.n5.nabble.com/creating-vtkImageData-from-byte-Java-tp5730013.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list