<div dir="ltr">Hello, everyone.<div><br></div><div>I am trying to do something quite simple: I have a raw image (and its corresponding .nhdr file) and I want to read it and save it in .nii format. The image type, according to the .nhdr file, is short. Below is the code I'm using. </div><div><br></div><div>My question is: what am I missing here? After I save the image to file and open it, I don't get the expected result; rather, I get an image that reminds a TV static. </div><div><br></div><div>Could you please help me?</div><div><br></div><div>Thanks in advance!</div><div><br></div><div>Best,</div><div>Paulo</div><div><br></div><div><div>#include <iostream></div><div>#include <itkImage.h></div><div>#include <itkImageFileWriter.h></div><div>#include <itkImageFileReader.h></div><div><br></div><div>int main(int argc, char* argv[])</div><div>{</div><div><br></div><div>  typedef itk::Image<short, 3> ImageType;</div><div><br></div><div>  if(argc < 3)</div><div>  {</div><div>    // programName <filename>.nhdr <filename>.nii</div><div>    std::cerr << "Usage: " << argv[0] << " Output1.nhdr Output2.nii\n";</div><div>    return EXIT_FAILURE;</div><div>  }</div><div><br></div><div>  // Read .nhdr file</div><div>  typedef itk::ImageFileReader< ImageType > ReaderType;</div><div>  ReaderType::Pointer reader = ReaderType::New();</div><div>  reader->SetFileName(argv[1]);</div><div>  reader->Update();</div><div><br></div><div>  // Save it as nii</div><div>  typedef itk::ImageFileWriter< ImageType > WriterType;</div><div>  WriterType::Pointer writer = WriterType::New();</div><div>  writer->UseInputMetaDataDictionaryOn(); // is this necessary?</div><div>  writer->SetInput(reader->GetOutput());</div><div>  writer->SetFileName(argv[2]);</div><div>  </div><div>  try</div><div>  {</div><div>    writer->Update();</div><div>  }</div><div>  catch(itk::ExceptionObject e)</div><div>  {</div><div>    std::cout << "Could not save image to file\n";</div><div>  }</div><div>  </div><div>  return EXIT_SUCCESS;</div><div>}</div></div><div><br></div><div><br></div></div><div dir="ltr">-- <br></div><div><div dir="ltr"><div>"Se podes olhar, vê. Se podes ver, repara."</div></div></div>