[vtkusers] Re: reading a stack of bmp files

megha agarwal megha_agar at yahoo.co.in
Thu Apr 8 04:26:03 EDT 2004


hi all,
Thanks to all who helped me regarding bmp files at last i have been able to read a series of bmp files.
The code that i have used is

For 99 bmp files of dimension 200*200 

  vtkBMPReader *Reader = vtkBMPReader::New();
  Reader-> SetHeaderSize(14);
  Reader->SetDataExtent (0,199,0,199,1,99);
  Reader->SetDataScalarTypeToUnsignedChar();
  Reader->SetDataByteOrderToLittleEndian();
  Reader->SetFilePrefix ("d:/bym280602b/n_"); // base file prefix for a series
  Reader->SetFilePattern ("%s%03d.bmp");
  Reader->Update();

   oTFun =vtkPiecewiseFunction::New();
   oTFun->AddPoint(0,0);
   oTFun->AddPoint(255,1);

 vtkPiecewiseFunction *gTFun =vtkPiecewiseFunction::New();
  gTFun->AddSegment(0,1.0,5,1.0);

   volProperty = vtkVolumeProperty::New();
   volProperty->SetColor(gTFun);
  volProperty->SetScalarOpacity(oTFun);
  volProperty->SetInterpolationTypeToLinear();
  volProperty->ShadeOn();
   
   vtkVolumeRayCastCompositeFunction *compositeFunction=   vtkVolumeRayCastCompositeFunction::New();
  volMapper = vtkVolumeRayCastMapper::New();
  volMapper->SetInput(Reader->GetOutput()); 
  volMapper->SetVolumeRayCastFunction(compositeFunction);

  vol=vtkVolume::New();
  vol->SetMapper(volMapper);  
  vol->SetProperty(volProperty);

 ren=vtkRenderer::New();
  ren->AddVolume(vol);  

   renwin=vtkRenderWindow::New();
  renwin->AddRenderer(ren);
    
  iren=vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renwin);
  renwin->Render();
  
 This is generating the image but in a distorted form. By distorted I mean that the points are getting overlapped, as a result I am not able to get the final correct image.

I think that the header size if bmp file is 14bytes and i have already set it. Is there some other property that i have to consider?

megha






















 be able to help you.
>
> V. Varadhan.
>
>> hello sir,
>>
>> as directed by you, i have tried reading a series of bmp files, but i am
>> unable to do so.
>> here is the code that i have used
>>
>> # For 512 x 512 images foo1 to foo100
>>
>> vtkBMPReader* bmp_d = vtkBMPReader::New();
>> bmp_d->SetFileName ("c:/foo"); // base file prefix for a series
>> bmp_d->SetFilePattern ("%s%d.bmp");
>> bmpData->SetDataExtent (0,511,0,511,1,100);
>> vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
>> mapper->SetInput( (vtkPolyData*) bmp_d->GetOutput());
>> vtkRenderer* ren = vtkRenderer::New();
>> vtkRenderWindow* renwin = vtkRenderWindow::New();
>> renwin->AddRenderer (ren);
>> vtkActor* actor = vtkActor::New();
>> actor->SetMapper (mapper);
>> ren->AddActor (actor);
>> renwin->Render();
>>
>> Please suggest
>>
>> Thanks for your help in advance
>> Megha
>>
>>
>> Win an evening with the Indian cricket captain: Yahoo! India Promos.
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>

_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: 
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers

Yahoo! India Matrimony: Find your partner online.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040408/bf9fcbfa/attachment.htm>


More information about the vtkusers mailing list