View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0006159 | ITK | public | 2007-12-13 13:25 | 2007-12-14 10:58 | |||||
Reporter | sebastienfricker | ||||||||
Assigned To | Bill Lorensen | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | closed | Resolution | fixed | ||||||
Platform | OS | OS Version | |||||||
Product Version | |||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0006159: itkTIFFImageIO does not close opened file | ||||||||
Description | It is not possible to overwrite a TIFF file in-place, ie read a file at the beginning of a pipeline and write to the same file at the end. The reason is that the file reader never closes the file it reads. In addition, when the writer fails to write, it does so silently. See the following code in Itktiffimageio.cxx, in the TIFFImageIO::InternalWrite function: TIFF *tif = TIFFOpen(m_FileName.c_str(), "w"); if ( !tif ) { itkDebugMacro( << "Returning" ); return; } | ||||||||
Additional Information | Example code: //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(); | ||||||||
Tags | No tags attached. | ||||||||
Resolution Date | |||||||||
Sprint | |||||||||
Sprint Status | |||||||||
Attached Files | |||||||||
Relationships | |
Relationships |
Notes | |
(0009868) Bill Lorensen (developer) 2007-12-13 13:36 |
I ran itkTIFFImageIOTest with a tiff file specified as the input and output. The program reported a cryptic error: TIFFOpen: garf.tif: Cannot open. |
(0009869) Bill Lorensen (developer) 2007-12-13 15:09 |
Placed m_InternalImage->Clean() after reads. This close the file and does some internal cleanup. Also replaced a DebugMacro with an exception if a file cannot be opend for writing. See: http://www.itk.org/cgi-bin/viewcvs.cgi/Code/IO/itkTIFFImageIO.cxx?rev=1.56&root=Insight&sortby=date&view=log [^] |
(0009890) Bill Lorensen (developer) 2007-12-14 10:58 |
Reporter confirmed a positive result of the bug fix. rom Sébastien Fricker <sebastien.fricker@phaseview.net> to Bill Lorensen <bill.lorensen@gmail.com>, cc Xabier Artaechevarria Artieda <xabiarta@unav.es>, insight-users@itk.org, date Dec 14, 2007 10:50 AM subject RE: [Insight-users] Overwriting TIFF files hide details 10:50 AM (7 minutes ago) Reply Bill, I tested it and it works perfectly now, so you can close the bug issue. Thanks a lot! Sebastien |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2007-12-13 13:25 | sebastienfricker | New Issue | |
2007-12-13 13:34 | Bill Lorensen | Status | new => assigned |
2007-12-13 13:34 | Bill Lorensen | Assigned To | => Bill Lorensen |
2007-12-13 13:36 | Bill Lorensen | Note Added: 0009868 | |
2007-12-13 13:36 | Bill Lorensen | Status | assigned => acknowledged |
2007-12-13 15:09 | Bill Lorensen | Status | acknowledged => resolved |
2007-12-13 15:09 | Bill Lorensen | Resolution | open => fixed |
2007-12-13 15:09 | Bill Lorensen | Note Added: 0009869 | |
2007-12-14 10:58 | Bill Lorensen | Status | resolved => closed |
2007-12-14 10:58 | Bill Lorensen | Note Added: 0009890 |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |