[vtkusers] How to write vtkImageData with vtkTIFFWriter?

lynx.abraxas at freenet.de lynx.abraxas at freenet.de
Sun Jan 10 16:35:46 EST 2010


On 10/01/10 14:20:01, lynx.abraxas at freenet.de wrote:
> Hello again!
> 
> 
> Another problem arose in my little test program (see below): How do I save the
> output of GaussianSplatter into a (3D) TIFF? What could convert the output  of
> GaussianSplatter to vtkImageData?

How comes vtkTIFFWriter cannot write vtkImageData? Is there something missing in vtkImageData that an image writer needs to know as well?

Thanks,
Lynx



> 
> 
> Thanks for any help or hint.
> Lynx
> 
> On 10/01/10 13:44:40, lynx.abraxas at freenet.de wrote:
> > Hello!
> > 
> > 
> > I have unstructured points (on a sphere). Each point has its own weight.
> > I   want   to  use  GaussianSplatter  but  with  a  ScaleFactor  (weight)  set
> > individually  for  each  point.  Sadly  the  wiki   example   does   not   use
> > scalarwarping.
> > How  do  I  get  a  scalar assigned to each point that then weights the splat?
> > SetScaleFactor weights all point same (if I'm not mistaken). I couldn't find a
> > setScalar for vtkPoints either.
> > Is it possible at all?
> > 
> > Thanks for any hint or help.
> > Lynx
> >
> 
> 
> #include <iostream>
> //#include <fstream>
> //#include <vector>
> #include <string>
> #include <sstream> //std::stringstream
>  
> //#include "vtkCellArray.h"
> #include "vtkPolyData.h"
> #include "vtkTIFFWriter.h"
> #include "vtkGaussianSplatter.h"
>  
> #include <cmath>
>  
> vtkPoints* ReadPoints(char* fn){
> //    std::string Filename = fn;        
> //    ifstream fin(Filename.c_str());
>     ifstream fin(fn);
>  
>     std::string line;
>     vtkPoints* Points = vtkPoints::New();
>  
>     while(getline(fin, line))
>         {
>         if (line[0] == '#'){
>             std::cerr << "Skipping line: " << line << std::endl;
>             continue;
>             }
>         unsigned int i;
>         double x,y,z,w;
>         std::stringstream linestream;
>         linestream << line;
>         linestream >> i >> x >> y >> z >> w;
>         printf("Adding point (%d): [%f;%f;%f] with weight: %f\n", i, x, y, z, w);
>         Points->InsertNextPoint(x, y, z);
>         Points->SetScalar(w);
>         }
>  
>     fin.close();
>  
>     return Points;
>     }
>  
> int main(int argc, char **argv) {
>  
>     vtkPoints* points = ReadPoints(argv[1]);
>     vtkPolyData* polydata = vtkPolyData::New();
>     polydata->SetPoints(points);
>  
>     vtkGaussianSplatter *Splatter = vtkGaussianSplatter::New();
>     Splatter->SetInput(polydata);
>     Splatter->SetSampleDimensions(atoi(argv[2]),atoi(argv[2]),atoi(argv[2])); //set the resolution of the final! volume
>     Splatter->SetRadius(atof(argv[3])); //GaussianSplat truncated outside Radius
>     Splatter->SetExponentFactor(atof(argv[4])); //GaussianSplat decay value
>     Splatter->ScalarWarpingOn();
>     //Splatter->SetScaleFactor(atof(argv[4]));//scale comes from each point
>  
>     vtkTIFFWriter *writer = vtkTIFFWriter::New();
>     std::cout << "Writinig TIFF..."; 
>     writer->SetFileName(argv[5]);
>     writer->SetInput(Splatter->GetOutput());
>     writer->Write();
>     std::cout << "done." << std::endl; 
> 
>     return 0;
>  
>     }
> 
> 
> 
> 
> PROJECT(GenerateSurfacefromUnstructuredPoints)
> CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
> 
> SET(CMAKE_INCLUDE_PATH /usr/local/lib/vtk-5.4)
> 
> FIND_PACKAGE(VTK REQUIRED)
> INCLUDE(${VTK_USE_FILE})
>  
> ADD_EXECUTABLE(gaus-spalt_01 gaus-spalt_01.cxx)
> TARGET_LINK_LIBRARIES(gaus-spalt_01 vtkHybrid)
> 
> 
>  
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK 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