[vtkusers] RecursiveWrite: Could not open file D:\readwrite1\liver11.vtk

shirani kannangara mangalika673 at gmail.com
Thu Jun 27 04:47:02 EDT 2013


Hi all
I have input a binary image in .vtk formt which could be visualize well
from itk snap. My next attempt is to write it.I used vtkmageReader2 to read
the file and and vtkmageWriter to write it. My codes are as follows.


int main(int argc, char *argv[])
{


  // Parse command line arguments
 //std::string inputFilename = "D:\\binary5\\skintriangulated1.mhd";

  // Read file
 vtkSmartPointer<vtkImageReader2> reader1 =
    vtkSmartPointer<vtkImageReader2>::New();
  reader1->SetFileName("D:\\binary5\\skintriangulated1.vtk");
  reader1->SetDataExtent(0, 674, 0, 400, 0, 449);
  reader1->SetDataSpacing(0.333,0.3333,0.3333);
  //reader1->SetDataScalarTypeToUnsignedChar();
  reader1->Update();


vtkSmartPointer<vtkImageWriter> writer =
      vtkSmartPointer<vtkImageWriter>::New();

 writer->SetFileName("D:\\readwrite\\skin11.vtk");
 writer->SetInputConnection(reader1->GetOutputPort());
 writer->Write();
 //writer->Update();

// Visualize

// Create an actor
  vtkSmartPointer<vtkImageActor> actor =
    vtkSmartPointer<vtkImageActor>::New();
  actor->SetInput(reader1->GetOutput());

  // Setup renderer
  vtkSmartPointer<vtkRenderer> renderer =
    vtkSmartPointer<vtkRenderer>::New();
  renderer->AddActor(actor);
  renderer->ResetCamera();

  // Setup render window
  vtkSmartPointer<vtkRenderWindow> renderWindow =
    vtkSmartPointer<vtkRenderWindow>::New();
  renderWindow->AddRenderer(renderer);

  // Setup render window interactor
  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
  vtkSmartPointer<vtkInteractorStyleImage> style =
    vtkSmartPointer<vtkInteractorStyleImage>::New();

  renderWindowInteractor->SetInteractorStyle(style);

  // Render and start interaction
  renderWindowInteractor->SetRenderWindow(renderWindow);
  renderWindowInteractor->Initialize();

  renderWindowInteractor->Start();

  return EXIT_SUCCESS;
}

Program was built with zero errors.But unable to open the output
("D:\\readwrite\\skin11.vtk")

It indicates  " imageRecursiveWrite: Could not open file
D:\readwrite1\liver11.vtk"
I can't understand this piece of writing.Can anybody please  correct me.

Regards

Shirani





imageRecursiveWrite: Could not open file D:\readwrite1\liver11.vtk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130627/a5ce4509/attachment.htm>


More information about the vtkusers mailing list