[Insight-users] Overwriting TIFF files

Xabier Artaechevarria Artieda xabiarta at unav.es
Thu Dec 13 12:20:45 EST 2007


Hi Sébastien,
I think I have done this, sometimes without even realising :(
Try writing with a different name to see if that is the  problem.
Good luck,
Xabi

-- 
Xabier Artaechevarria
Cancer Imaging Laboratory
Centre for Applied Medical Research
www.cima.es



Sébastien Fricker <sebastien.fricker at phaseview.net> ha escrito:

> Dear ITK users,
>
> I wrote a program that opens an image, transforms it via the Resample image
> filter and writes the result to the original image file (see code fragment
> below).
>
> This works fine when I use BMP images.
>
> It does not work when I use TIF images: the original image is not modified.
> What happens is that the writer at the end does not do anything: apparently
> it cannot open the image for writing, probably because the same image was
> open for reading at the beginning of the pipeline.
>
>
>
> Is this a bug or am I doing something wrong?
>
> How can I modify a TIF file in-place?
>
>
>
> Thanks for any hint.
>
>
>
> Sebastien
>
>
>
> CODE FRAGMENT:
>
>
>
> --------------------------------------------------------
>
>
>
> //DEFINE IMAGE TYPES
>
> const unsigned int Dimension = 2;
>
> typedef unsigned short PixelType;
>
> typedef double InternalPixelType;
>
> typedef itk::Image< PixelType, Dimension > ImageType;
>
> typedef itk::Image< InternalPixelType, Dimension > InternalImageType;
>
>
>
> //READ INPUT IMAGE
>
> typedef itk::ImageFileReader< ImageType  > ImageReaderType;
>
> ImageReaderType::Pointer  inputImageReader  = ImageReaderType::New();
>
>
>
> inputImageReader->SetFileName( fileName );
>
> inputImageReader->Update();
>
> ImageType::Pointer inputImage = inputImageReader->GetOutput();
>
>
>
>
>
> //RESAMPLE IMAGE
>
> //Define filter, create one instance
>
> typedef itk::ResampleImageFilter< InternalImageType, InternalImageType >
> ResampleFilterType;
>
> ResampleFilterType::Pointer resampler = ResampleFilterType::New();
>
>
>
> resampler->SetInput( inputImage );
>
>
>
> //MORE CODE HERE TO SET RESAMPLER PARAMETERS 

>
>
>
>
>
> //CAST IMAGE TO OUTPUT TYPE
>
> typedef itk::CastImageFilter<
>
>                              InternalImageType,
>
>                              ImageType > CastFilterType;
>
> CastFilterType::Pointer  caster =  CastFilterType::New();
>
>
>
> caster->SetInput( resampler->GetOutput() );
>
>
>
> //WRITE OUTPUT FILE
>
> typedef itk::ImageFileWriter< ImageType >  WriterType;
>
> WriterType::Pointer      writer =  WriterType::New();
>
>
>
> writer->SetFileName( fileName );
>
> writer->SetInput( caster->GetOutput() );
>
> writer->Update();
>
>
>
> --------------------------------------------------------
>
>
>
>
>
>



----------------------------------------------------------------
Este mensaje ha sido enviado desde https://webmail.unav.es



More information about the Insight-users mailing list