[vtkusers] Re: reading a stack of bmp files

Veerapuram Varadhan v.varadhan at californiadigital.com
Thu Apr 8 05:11:07 EDT 2004


Hi,

I don't think there is any need for SetHeaderSize().  Even if you set, i
think vtkBMPReader is not affected by it.

Sorry that I am not able to identify the culprit in particular in code,
however, would suggest using vtkImageActor and do a simple rendering to
check whether the data that is read by the vtkBMPReader is good or not.

after Reader->Update();

vtkImageActor* imageActor = vtkImageActor::New();
imageActor->SetInput (Reader->GetOutput());
...
...
...
ren->AddActor (imageActor);

HTH,

V. Varadhan.


>
> 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.




More information about the vtkusers mailing list