[Insight-users] ConfidenceConnectedImageFilter???

Luis Ibanez luis.ibanez@kitware.com
Thu, 30 Jan 2003 10:11:17 -0500


Hi Waltraud,

ITK does not have an ImageIO object that
supports reading/writing image in PIC format.

When you give a filename with extension ".pic"
to the ImageFilteReader, it will look for an
ImageIO object capable of recognizing this
extension. If no ImageIO object is found, the
ImageFileReader will throw an exception.

Please convert your PIC files to PNG, Gipl,
Analyze, Meta or VTK formats (for which ITK
do have ImageIO objects).

If you are familiar with the PIC format you
are also welcome to contribute a reader to ITK.

A very modular architecture for IO have been
put in place allowing addition of any number
of file formats without any changes to the
ImageFileReader or Writer. You may find some
details on this architecture in the
SoftwareGuide.pdf under the section:

     "Reading and Writing Images"

----------------------

Now, in your second try, the filename that
you are passing to the writer does not have
any extension.

 >
 >   writer->SetFileName("ConfidenceGrowing" );
 >

Whitout extension, the ImageIO factory mechanism
can not figure out what kind of file format
do you want to use. ( Neither do I...  :-) ).

An easy turn around  is to explicitly create
the ImageIO object corresponding to the file
format you want to use.

For example, for PNG you may do the following:

#include <itkPNGImageIO.h>

....

itk::PNGImageIO::Pointer imageIO = itk::PNGImageIO::New();

writer->SetImageIO(  imageIO  );
writer->SetFileName("ConfidenceGrowing");
writer->SetInput( filter->GetOutput() );
writer->Update();


That will save your image in PNG format. With
the filename "ConfidenceGrowing". Note that no
extension will be added to your filename. So,
still, you may have trouble trying to read this
image back. (Is there any particular reason why
you  don't want to use extensions ?)


Please let us know if you have further questions.


   Thanks


      Luis



-----------------------------------
Waltraud Henrich wrote:
> 
> Hello,
> 
> I work with ConfidenceConnectedImageFilter in order to get the binary image.
> I try the example with my pic files in 3D but it did not go, I get the
> following mistake 
> m_Description	{0x05a43f69 "itk::ERROR: ImageFileWriter(05A273B8): No
> ImageIO set, or none could be created."}
> 
> so that I try the example in Examples/Segmentation/ConfidenceConnected.cxx.
> It's almost completely the example, except the market(**) lines. I get the
> following mistake: " Access Violation."in the following line
> writer->Update();
> Why?
> 
> 
> 
> void RegionGrowingModel::ConfidenceConnected()
> {	
> 	const     unsigned int    Dimension = 2;
> 	typedef itk::Image<float, Dimension> InternalImageType;
> 	
> 	
>  	 typedef itk::Image<unsigned char, Dimension> ImageTypeUCHAR;
>  	 typedef unsigned char OutputPixelType;
>   	typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
> 
>   	typedef itk::CastImageFilter< 
>                         InternalImageType, 
>                         OutputImageType    >    CastingFilterType;
>   
>   	CastingFilterType::Pointer caster = CastingFilterType::New();
>                         
>   //
>   // We instantiate reader and writer types
>   //
>   
>  	 typedef  itk::ImageFileReader< InternalImageType > ReaderType;
>  	 typedef  itk::ImageFileWriter<  OutputImageType  > WriterType;
> 
>   	ReaderType::Pointer reader = ReaderType::New();
>  	 WriterType::Pointer writer = WriterType::New();
> 
>   	**	 const char*
> filename="D:/user/henrich/pngDaten/BrainProtonDensitySlice.png";n
>   	** 	reader->SetFileName(filename );  
>   
>   
>  	** 	 writer->SetFileName("ConfidenceGrowing" );
> 
> 
>  	 typedef   itk::CurvatureFlowImageFilter< 
>                                InternalImageType, 
>                                InternalImageType >
> CurvatureFlowImageFilterType;
> 
>   	CurvatureFlowImageFilterType::Pointer smoothing = 
>                          CurvatureFlowImageFilterType::New();
>   
>   
>   	typedef  itk::ConfidenceConnectedImageFilter< 
>                                     InternalImageType, 
>                                     InternalImageType > ConnectedFilterType;
>  
>  	 ConnectedFilterType::Pointer confidenceConnected =
> ConnectedFilterType::New();
>   
> 
> 	smoothing->SetInput( reader->GetOutput() );
> 
>   	confidenceConnected->SetInput( smoothing->GetOutput() );
> 
>   	caster->SetInput( confidenceConnected->GetOutput() );
> 
>   	writer->SetInput( caster->GetOutput() );
>   
>   	smoothing->SetNumberOfIterations( 5 );
> 
>   	smoothing->SetTimeStep( 0.25 );
>   
>   	confidenceConnected->SetMultiplier( 2.5 );
>   
>   	confidenceConnected->SetNumberOfIterations( 5 );
>   
>  	 confidenceConnected->SetReplaceValue( 255 );
>  
> 
>  	 InternalImageType::IndexType  index;
> 
> 
> 	**	 index[0] =  60;
> 	**	 index[1] =  116;
> 
>   
>   
> 	  confidenceConnected->SetSeed( index );
>   
>  	 confidenceConnected->SetInitialNeighborhoodRadius( 2 );
>   
>   
> 	  try
>    	 {
>    	 writer->Update();
>     	}
> 	  catch( itk::ExceptionObject & excep )
>    	 {
>     	std::cerr << "Exception caught !" << std::endl;
>   	  std::cerr << excep << std::endl;
>    	 }
>   
>  
> }
> 
> 
> 
> Thanks in advance.
> 
> Waltraut
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
> 
>