[vtkusers] Save a 3D in a series of PNG images (reconstruction possible)

Bill Lorensen bill.lorensen at gmail.com
Mon Dec 22 13:10:04 EST 2008


Try something like:

writer->SetFilePrefix(koursky);
writer->SetFilePattern("%s%d.png");

Do not
writer->SetFileName(wfname);

PNG can only store 2D images. If you set the file name, I think it
writes each 2d image into the same file, so will will just see the
last file. Using SetFilePrefix and SetFilePattern will generate a
uniquq file for each 2D image. In your case, koursky1.png,
koursky2.png, ...

If you need to store all of your images in one file, then use a format
that supports 3D, e.g.  vtkMetaImageWriter.


On Sat, Dec 13, 2008 at 5:40 AM, Matthieu Duvinage
<matthieu.duvinage at gmail.com> wrote:
> Hi everybody,
>
> In fact, I need to save a thresholded data in PNG files. For example, the
> threshold data is given below, and I need to store this data into PNG files
> and to be able to reconstruct the Vol data only thanks to these PNG files. I
> have noticed that vtkPNGWriter is able to write 3D images but I don't have a
> set of PNG files when I tried it. Moreover, the image I get is a black PNG
> file.
>  Do you have an idea ?
> The other goal is to use PNG files from another application and to be able
> to reconstruct the overall data and to render it. I suppose that the use of
> vtkPNGreader allows this ?
>
> Thanks
>
> Matthieu
>
> (avec vtkImageVOLReader* Vol = vtkImageVOLReader::New();)
>
> vtkImageThreshold *mon_tre = vtkImageThreshold::New();
>     mon_tre->SetInput(Vol->GetOutput());
>     mon_tre->ThresholdByUpper(1300);
>     mon_tre->SetInValue(0);
>     mon_tre->SetOutValue(255);
>     //mon_tre->ReplaceOutOff();
>     //mon_tre->ReplaceInOn();
>     mon_tre->Update();
>
> vtkPNGWriter *writer=vtkPNGWriter::New();
>     //w2i->SetInput(renWin);
>     writer->SetInput(mon_tre->GetOutput());
>     char *wfname=(char *)malloc(sizeof(char)*25);
>     sprintf(wfname,"koursky2.png");
>
>     writer->SetFileName(wfname);
>     //renWin->Render();
>     //w2i->Update();
>     writer->Write();
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list