<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 = &quot;D:\\binary5\\skintriangulated1.mhd&quot;;</div>
<div> </div><div>  // Read file</div><div> vtkSmartPointer&lt;vtkImageReader2&gt; reader1 =</div><div>    vtkSmartPointer&lt;vtkImageReader2&gt;::New();</div><div>  reader1-&gt;SetFileName(&quot;D:\\binary5\\skintriangulated1.vtk&quot;);</div>
<div>  reader1-&gt;SetDataExtent(0, 674, 0, 400, 0, 449);</div><div>  reader1-&gt;SetDataSpacing(0.333,0.3333,0.3333);</div><div>  //reader1-&gt;SetDataScalarTypeToUnsignedChar();</div><div>  reader1-&gt;Update();</div><div>
<br></div><div><br></div><div>vtkSmartPointer&lt;vtkImageWriter&gt; writer =</div><div>      vtkSmartPointer&lt;vtkImageWriter&gt;::New();</div><div> </div><div> writer-&gt;SetFileName(&quot;D:\\readwrite\\skin11.vtk&quot;);</div>
<div> writer-&gt;SetInputConnection(reader1-&gt;GetOutputPort());</div><div> writer-&gt;Write(); </div><div> //writer-&gt;Update();</div><div><br></div><div>// Visualize</div><div>  </div><div>// Create an actor</div><div>
  vtkSmartPointer&lt;vtkImageActor&gt; actor =</div><div>    vtkSmartPointer&lt;vtkImageActor&gt;::New();</div><div>  actor-&gt;SetInput(reader1-&gt;GetOutput());</div><div> </div><div>  // Setup renderer</div><div>  vtkSmartPointer&lt;vtkRenderer&gt; renderer =</div>
<div>    vtkSmartPointer&lt;vtkRenderer&gt;::New();</div><div>  renderer-&gt;AddActor(actor);</div><div>  renderer-&gt;ResetCamera();</div><div> </div><div>  // Setup render window</div><div>  vtkSmartPointer&lt;vtkRenderWindow&gt; renderWindow =</div>
<div>    vtkSmartPointer&lt;vtkRenderWindow&gt;::New();</div><div>  renderWindow-&gt;AddRenderer(renderer);</div><div> </div><div>  // Setup render window interactor</div><div>  vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; renderWindowInteractor =</div>
<div>    vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();</div><div>  vtkSmartPointer&lt;vtkInteractorStyleImage&gt; style =</div><div>    vtkSmartPointer&lt;vtkInteractorStyleImage&gt;::New();</div><div> </div><div>
  renderWindowInteractor-&gt;SetInteractorStyle(style);</div><div> </div><div>  // Render and start interaction</div><div>  renderWindowInteractor-&gt;SetRenderWindow(renderWindow);</div><div>  renderWindowInteractor-&gt;Initialize();</div>
<div> </div><div>  renderWindowInteractor-&gt;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 (&quot;D:\\readwrite\\skin11.vtk&quot;)</div>
<div style><br></div></div><div style>It indicates  &quot; imageRecursiveWrite: Could not open file D:\readwrite1\liver11.vtk&quot;</div><div style>I can&#39;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>