[ITK] [ITK-users] Windows Levels after write

Matias Montroull matimontg at gmail.com
Thu May 12 09:56:36 EDT 2016


Hi,

I've written code to flip an image in its X axis, it work fine but for some
reason, the flipped image has its window levels changed...
Original image has WW 40 and WC 400 and the resulting image has WW -435 and
WC 5178.
*The images I'm trying are signed short Dicom files.*
The original file has rescaleintercept -1024 and the resulting image has
this value set to 0 which is also strange

Any reason why this happens?

Here's the code:

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkFlipImageFilter.h"

int main(int argc, char* argv[])
{
if (argc != 4)
{
std::cerr << "Usage: " << argv[0];
std::cerr << " <InputFileName> <OutputFileName> <AxisToFlip>";
std::cerr << std::endl;
return EXIT_FAILURE;
}

typedef itk::Image< signed short, 2 >  ImageType;

typedef itk::ImageFileReader< ImageType >   ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);

typedef itk::FlipImageFilter< ImageType >   FlipImageFilterType;

FlipImageFilterType::Pointer flipFilter = FlipImageFilterType::New();

flipFilter->SetInput(reader->GetOutput());

FlipImageFilterType::FlipAxesArrayType flipAxes;
if (atoi(argv[3]) == 0)
{
flipAxes[0] = true;
flipAxes[1] = false;
}
else
{
flipAxes[0] = false;
flipAxes[1] = true;
}

flipFilter->SetFlipAxes(flipAxes);

typedef itk::ImageFileWriter< ImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(argv[2]);
writer->SetInput(flipFilter->GetOutput());
try
{
writer->Update();
}
catch (itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}

-- 
Matias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20160512/76b1ff34/attachment.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list