<div dir="ltr"><div> </div><div style>Hi all</div><div style>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.</div>
<div style><br></div><div style><br></div><div style><div>int main(int argc, char *argv[])</div><div>{</div><div> </div><div> </div><div> // Parse command line arguments</div><div> //std::string inputFilename = "D:\\binary5\\skintriangulated1.mhd";</div>
<div> </div><div> // Read file</div><div> vtkSmartPointer<vtkImageReader2> reader1 =</div><div> vtkSmartPointer<vtkImageReader2>::New();</div><div> reader1->SetFileName("D:\\binary5\\skintriangulated1.vtk");</div>
<div> reader1->SetDataExtent(0, 674, 0, 400, 0, 449);</div><div> reader1->SetDataSpacing(0.333,0.3333,0.3333);</div><div> //reader1->SetDataScalarTypeToUnsignedChar();</div><div> reader1->Update();</div><div>
<br></div><div><br></div><div>vtkSmartPointer<vtkImageWriter> writer =</div><div> vtkSmartPointer<vtkImageWriter>::New();</div><div> </div><div> writer->SetFileName("D:\\readwrite\\skin11.vtk");</div>
<div> writer->SetInputConnection(reader1->GetOutputPort());</div><div> writer->Write(); </div><div> //writer->Update();</div><div><br></div><div>// Visualize</div><div> </div><div>// Create an actor</div><div>
vtkSmartPointer<vtkImageActor> actor =</div><div> vtkSmartPointer<vtkImageActor>::New();</div><div> actor->SetInput(reader1->GetOutput());</div><div> </div><div> // Setup renderer</div><div> vtkSmartPointer<vtkRenderer> renderer =</div>
<div> vtkSmartPointer<vtkRenderer>::New();</div><div> renderer->AddActor(actor);</div><div> renderer->ResetCamera();</div><div> </div><div> // Setup render window</div><div> vtkSmartPointer<vtkRenderWindow> renderWindow =</div>
<div> vtkSmartPointer<vtkRenderWindow>::New();</div><div> renderWindow->AddRenderer(renderer);</div><div> </div><div> // Setup render window interactor</div><div> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =</div>
<div> vtkSmartPointer<vtkRenderWindowInteractor>::New();</div><div> vtkSmartPointer<vtkInteractorStyleImage> style =</div><div> vtkSmartPointer<vtkInteractorStyleImage>::New();</div><div> </div><div>
renderWindowInteractor->SetInteractorStyle(style);</div><div> </div><div> // Render and start interaction</div><div> renderWindowInteractor->SetRenderWindow(renderWindow);</div><div> renderWindowInteractor->Initialize();</div>
<div> </div><div> renderWindowInteractor->Start();</div><div> </div><div> return EXIT_SUCCESS;</div><div>}</div><div><br></div><div style>Program was built with zero errors.But unable to open the output ("D:\\readwrite\\skin11.vtk")</div>
<div style><br></div></div><div style>It indicates " imageRecursiveWrite: Could not open file D:\readwrite1\liver11.vtk"</div><div style>I can't understand this piece of writing.Can anybody please correct me.</div>
<div style><br></div><div style>Regards </div><div style><br></div><div style>Shirani</div><div style><br></div><div style><br></div><div style><br></div><div style><br></div><div style><br></div><div style>imageRecursiveWrite: Could not open file D:\readwrite1\liver11.vtk<br>
</div><div><br></div></div>