[vtkusers] create ImageData

Sebastian Arkenau arkenau at v2t.de
Fri Jun 6 08:59:54 EDT 2003


Hi,

i tried to create my own ImageData with visualisation in the vtkImageViewer.
This works fine with Type unsigned char. Then I tried the same example with
type float and it did not work. Here is the full example of my code.

vtkImageData *id = vtkImageData::New();
id->SetDimensions(256,256,256);
id->SetScalarTypeToUnsignedChar();
//id->SetScalarTypeToFloat()
id->AllocateScalars();
unsigned char *ptr = (unsigned char *) id->GetScalarPointer();      //the
same with float
for(int i=0;i<256;i++)
    for(int j=0;j<256;j++)
         for(int k=0;k<256;k++)
             *ptr++= i+j+k;
cout << id->GetScalarTypeMin() << endl;
cout << id->GetScalarTypeMax() << endl;
vtkImageViewer *view = vtkImageViewer::New();
view->SetInput(id);
view->SetColorWindow(400);
view->SetColorLevel(0);
for (int i=0;i<256;++i){
view->SetZSlice(i);
view->Render();
}
This works fine and the same example with float did not work?.

Is anybody outside who can help me??

Thanks


Sebastian Arkenau

V2T VISION TO TECHNOLOGY GmbH
Max-Planck-Strasse (Gebäude GITZ)
D-21502 Geesthacht

Tel.: ++49 (0) 4152 / 889 22 - 0
Fax.: ++49 (0) 4152 / 889 23 - 2
EMail: arkenau at v2t.de
Web: www.v2t.de

Sitz der Gesellschaft: Geesthacht
AG Geesthacht / HRB 679 / Ust-ID: DE218814753
Geschäftsführer: Christian M. Senet, Dr. Jörg Seemann





More information about the vtkusers mailing list