[Insight-users] JPEG files IO problem

Julien Jomier jjomier at cs . unc . edu
Mon, 24 Nov 2003 15:55:23 -0500


Hi Fucang,

Thanks for the bug report,

I reproduced your problem, for an 'unknown' reason (lack of coffee maybe :)
) the file was opened two times in the Write() function.

I just put the fix in the cvs repository.

Let us know if you have any further problem,

Thanks again for the bug report!

Julien

> -----Original Message-----
> From: insight-users-admin at itk . org 
> [mailto:insight-users-admin at itk . org] On Behalf Of Fucang Jia
> Sent: Monday, November 24, 2003 11:28 AM
> To: insight-users at itk . org
> Subject: [Insight-users] JPEG files IO problem
> 
> 
> Hi, everyone,
> 
> When I use multiple file to read or write, and the image 
> format is JPEG, the 
> program throw an exception when it handles about 509 files. I 
> think this is 
> because the itkJPEGImageIO.cxx does not
> close the FILE pointer fp. When I use "fcloseall();" in the 
> program , the 
> problem does not occur.
> 
> ExceptionObject caught !
> 
> itk::ExceptionObject (00E8F7AC)
> Location: "Unknown"
> File: H:\cvs_11_20\Insight\Code\IO\itkJPEGImageIO.cxx
> Line: 522
> Description: itk::ERROR: JPEGImageIO(0027D290): Error 
> JPEGImageIO could not 
> open file: roi_0508.jpg
> 
> 
> Thank you!
> 
> Fucang
> 
> ==========================
> 
> The demo program is as follows:
> 
> #include "itkRGBPixel.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkJPEGImageIO.h"
> #include "itkExtractImageFilter.h"
> #include "itkImage.h"
> 
> int main( int argc, char ** argv )
> {
> 
> 	typedef itk::RGBPixel<unsigned char>           PixelType;
> 
> 	const   unsigned int        Dimension = 2;
> 
> 	typedef itk::Image< PixelType, Dimension >     ImageType;
> 	typedef itk::Image< PixelType, Dimension >     ImageType;
> 	typedef itk::ImageFileReader< ImageType  >     ReaderType;
> 	typedef itk::ImageFileWriter< ImageType >      WriterType;
> 
> 	ReaderType::Pointer reader = ReaderType::New();
> 	WriterType::Pointer writer = WriterType::New();
> 
> 	typedef itk::ExtractImageFilter< ImageType, ImageType > 
> FilterType;
> 
> 	FilterType::Pointer filter = FilterType::New();
> 
> 	ImageType::IndexType  start;
> 	ImageType::SizeType   size;
> 	ImageType::RegionType wantedRegion;
> 
> 	start[0] = 10;
> 	start[1] = 10;
> 	size[0]  = 50;
> 	size[1]  = 50;
> 
> 	wantedRegion.SetSize(  size  );
> 	wantedRegion.SetIndex( start );
> 	filter->SetExtractionRegion( wantedRegion );
> 
> 	char intputFileName[256];
> 	char outputFileName[256];
> 
> 	for(int i=0;i<1024;i++)
> 	{
> 
> 		sprintf(intputFileName,"org_%04d.jpg",i);
> 		sprintf(outputFileName,"roi_%04d.jpg",i);
> 
> 		reader->SetFileName( intputFileName );
> 		writer->SetFileName( outputFileName );
> 		filter->SetInput( reader->GetOutput() );
> 		writer->SetInput( filter->GetOutput() );
> 
> 		try
> 		{
> 			writer->Update();
> 		}
> 		catch( itk::ExceptionObject & err )
> 		{
> 			std::cout << "ExceptionObject caught !" 
> << std::endl;
> 			std::cout << err << std::endl;
> 			return -1;
> 		}
> 
> 
> 		//fcloseall();
> 
> 	}
> 
> 
> 	return 0;
> }
> 
> _________________________________________________________________
> MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. 
> http://join . msn . com/?page=features/virus
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org 
> http://www . itk . org/mailman/listinfo/insight-> users
>