[vtkusers] Saving result of volume rendering in a .pgm 2D image

Miro Drahos mdrahos at robodoc.com
Fri Nov 8 13:56:24 EST 2013


I don't know what is .pgm format, but for any image you could just use 
vtkWindowToImageFilter, pass your renderwindow to it as input, and then 
use the writer with it, e.g.:

void savePNG(const char * filename, vtkRenderWindow * rw)
{
   vtkWindowToImageFilter * w2i = vtkWindowToImageFilter::New();
   w2i->SetInput(rw);   // rw is vtkRenderWindow that you are painting into
   w2i->SetInputBufferTypeToRGBA();
   w2i->Update();

   vtkPNGWriter *writer = vtkPNGWriter::New();
   writer->SetInputConnection(w2i->GetOutputPort());
   writer->SetFileName(filename);

   rw->SetSize(800, 800);
   rw->Render();
   writer->Write();

   w2i->Delete();
   writer->Delete();
}

Cheers,
Miro


On 11/05/2013 09:31 PM, R R wrote:
> Hello all,
>
> I have a question about how we can save the result of volume rendering 
> in .pgm format. I mean I have a volume from which a 2D image is 
> created using raycasting and is shown on the screen. I want to save 
> this 2D image in a .pgm file. Could any body please give me some hint 
> how I can do that.
>
> Thanks so much.
>
> Regards,
> Rane

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20131108/20e51097/attachment.htm>


More information about the vtkusers mailing list