[vtkusers] Create 16 bit grayscale gradient and show this image

mailagentrus mailagentrus at mail.ru
Fri Aug 17 04:22:52 EDT 2012


Hi! Can you help me with creating 16 bit grayscale gradient image?  

unsigned short buffer[1024*1024*2];
unsigned short k=0;
for (int i = 0; i<512;i++) 
{ k=0;
  for (int j=0; j<512;j++) 
  {
    buffer[i*512*2+j*2+1]=(k) & 0xff;  // low byte
    buffer[i*512*2+j*2]=(k>>8) & 0xff; // high byte
    k++;
  }
}

vtkImageImport *importer = vtkImageImport::New();
  importer->SetWholeExtent(0,511,0,511,0,0);
  importer->SetDataExtentToWholeExtent();
  importer->SetNumberOfScalarComponents(1);
  importer->SetDataScalarTypeToUnsignedShort();
  importer->SetImportVoidPointer(buffer);

vtkSmartPointer<vtkImageViewer2> imgViewer =
vtkSmartPointer<vtkImageViewer2>::New();
imgViewer->SetInputConnection(importer->GetOutputPort());
imgViewer->Render();

But I see only 8 bit gradient image (only 8 bit)... 
http://vtk.1045678.n5.nabble.com/file/n5715373/%D0%91%D0%B5%D0%B7%D1%8B%D0%BC%D1%8F%D0%BD%D0%BD%D1%8B%D0%B9.png 



--
View this message in context: http://vtk.1045678.n5.nabble.com/Create-16-bit-grayscale-gradient-and-show-this-image-tp5715373.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list