[Insight-users] Re: Problem using Discrete Guassian Filter..Blank Image

Luis Ibanez luis.ibanez@kitware.com
Fri, 07 Mar 2003 21:22:11 -0500


Hi Shilpa,

Your code looks good,

This sounds like a writing problem.
Note that you don't need to set the PNGImageIO
writer any more. The factory mechanism should
be able to find the right ImageIO based on the
extension of the output filename.



1)  What format are you providing for the output image ?
     is it png ?

    remember that it is important to provide the right
    extension with the file name.  Given that you are
    fixing the PNG writer, if you provide any other
    extension, the writing process will fail.


2) Have you tried any of the images in

    Insight/Examples/Data    ?

3) Have you experimented with the example of this
    filter in the Insight/Examples/Filtering
    directory ?

       DiscreteGaussianImageFilter.cxx


---


I suggest you to start by trying the example in
Examples/Filtering, using the image in Examples/Data.
Once that works for you, it is then time to play
with the parameters and map the same to your own
example code.


Let us know if you have further questions.

Thanks


Luis



-----------------------
shilpa kinkar wrote:
> Hi Luis,
> 
> Still I am facing problem using Discrete Guassina Filter.....Probelm is :
> 
> No matter what the values for Variance and kernalwidth, output image is 
> always of 179 Bytes while input image is of 17 K ( I am using ITK LOGO 
> image image001.png of size 400 * 256 ) Values i have tried are ( 
> variance , kernalWidth ):
> 
> 1.    2, 4  
> 
> 2.    4,6
> 
> 3.    6, 8
> 
> 4.    8, 10 and some other values
> 
> I don't understand why output image is not displayed. ( image is just 
> black rectangle  and of size 179 bytes )
> 
> I have used follwing code ---> ( doesn't seem anything wrong in code 
> though )
> 
> ----------------------------------------------------------------------------------------------------------------
> 
> typedef itk::Image<unsigned char, 2> ImageType;
> 
> try
>   {
>     // Instantiate a reader for the file.   
>    typedef itk::ImageFileReader<ImageType> ImageReaderType;   
>    ImageReaderType::Pointer reader = ImageReaderType::New();
>    reader->SetFileName(argv[1]);   
> 
>    // Instantiate a filter and attach it to the reader.
> 
>    typedef itk::DiscreteGaussianImageFilter<ImageType, ImageType > 
> FilterType;
>    FilterType::Pointer filter = FilterType::New();        
>    filter->SetInput( reader->GetOutput() );
>    filter->SetVariance( gaussianVariance );
>    filter->SetMaximumKernelWidth( maxKernelWidth );
> 
>    // Instantiate a writer and attach it to the filter.
>    typedef itk::ImageFileWriter<ImageType> ImageWriterType;
>    ImageWriterType::Pointer writer = ImageWriterType::New();
>    writer->SetImageIO(itk::PNGImageIO::New());
>    writer->SetInput(filter->GetOutput());
>    writer->SetFileName(argv[2]);
> 
>    // Execute the process
>    try
>         {
>             writer->Update();
>         }
>   catch( itk::ExceptionObject & e )
>   {
>     std::cerr << "Exception caught during PNG file reading " << std::endl;
>     std::cerr << e << std::endl;
>     return -1;
>    }  
> 
>   }  // End of main try block
>   
> 
> catch(itk::ExceptionObject &err)
>   {
>    std::cerr << err << std::endl;
>    return 1;
>   }
> ----------------------------------------------------------------------------------------------------------------
> 
> Thanks,
> 
> Neha
> 
> 
> ------------------------------------------------------------------------
> Do you Yahoo!?
> Yahoo! Tax Center 
> <http://rd.yahoo.com/finance/mailtagline/*http://taxes.yahoo.com/> - 
> forms, calculators, tips, and more