[Insight-users] problem with discrete gaussian filter

Luis Ibanez luis.ibanez at kitware.com
Tue Jul 28 06:35:05 EDT 2009


Hi Syrine,

As described in the ITK Software Guide

     http://www.itk.org/ItkSoftwareGuide.pdf

all the examples in the directory:

               Insight/Examples

are intended to be run as command line executables.

This means that you must run them from:

    A) a GNU/Linux shell (in a terminal)   or
    B) a MS-DOS command window on Windows or
    C) a Visual Studio command prompt window


What is your platform ?
(Windows?, Linux?, Mac? other ?).

You should familiarize yourself, first, with using a command
line interface. Then you will be comfortable running the examples.


Once you are familiar with the examples, you can run them as:


> executable  input1 input2  output


for example, the Median filter example in

       Insight/Examples/Filtering

will work as:

> MedianImageFilter   BrainProtonDensitySlice.png  median.png

You will find ALL the images used for the ITK Software Guide,
in the directory:

      Insight/Testing/Data

(including the BrainProtonDensitySlice.png mentioned above).



---

About your process for reading a DICOM image, the problem
is that you are using the ImageFileReader, while you should be
using the ImageSeriesReader.


In your current code, you are only reading one slice of the
DICOM series.


Please read the ITK Software Guide

     http://www.itk.org/ItkSoftwareGuide.pdf

in particular the chapter "Reading and Writing Images", it has
detailed explanations on how to read a series of DICOM images
from a directory.

You will find useful to look at the Example:

     Insight/Examples/IO/
         DicomSeriesReadImageWrite2.cxx




      Regards,


            Luis



----------------------------------------------------------------------------------------------------------------
On Tue, Jul 28, 2009 at 5:26 AM, Syrine Sahmim <syrine.sahmim at yahoo.fr>wrote:

> Hello every body,
> Yesterday i sent an email to the group to know what is the problem with my
> code and i did not receive answer.
> I want to understand some things at the begining:
> 1. when i try the examples programs, i must give to the program the images
> as input. the problem is that i can't do that , i don't know how and where i
> must gives the input image and the out put one. if someone can explain more
> this issue to me.
> 2. i send again my previous program to try to find errors.
> I try to apply the discrete gaussian filter on a 3D dicom image. So i tried
> the code below. there's no errors on building step but the problem is after
> debugging. i don't have result.so i want to know where's the error or even i
> must do or add some codes to succeed execution.
> the code is:
> #if defined(_MSC_VER)
> #pragma warning ( disable : 4786 )
> #endif
>
> #ifdef __BORLANDC__
> #define ITK_LEAN_AND_MEAN
> #endif
>
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkRescaleIntensityImageFilter.h"
>
>
> #include "itkDiscreteGaussianImageFilter.h"
>
> int main( int argc, char * argv[] )
> {argc = 2;
>     argv[1] = "003F87DA.png";
>     argv[2] = "DA.png";
>   /*if( argc < 3 )
>     {
>     std::cerr << "Usage: " << std::endl;
>     std::cerr << argv[0] << "  inputImageFile  outputImageFile  variance
> maxKernelWidth " << std::endl;
>     return EXIT_FAILURE;
>     }*/
>
>
>   typedef    float    InputPixelType;
>   typedef    float    OutputPixelType;
>
>   typedef itk::Image< InputPixelType,  3 >   InputImageType;
>   typedef itk::Image< OutputPixelType, 3 >   OutputImageType;
>
>   typedef itk::ImageFileReader< InputImageType >  ReaderType;
>
>
>
>   typedef itk::DiscreteGaussianImageFilter<
>                  InputImageType, OutputImageType >  FilterType;
>
>   FilterType::Pointer filter = FilterType::New();
>
>   ReaderType::Pointer reader = ReaderType::New();
>   reader->SetFileName( argv[1] );
>
>   filter->SetInput( reader->GetOutput() );
>
>   const double gaussianVariance = atof( argv[3] );
>   const unsigned int maxKernelWidth = atoi( argv[4] );
>
>   filter->SetVariance( gaussianVariance );
>   filter->SetMaximumKernelWidth( maxKernelWidth );
>
>
>   filter->Update();
>
>   typedef unsigned char WritePixelType;
>   typedef itk::Image< WritePixelType, 2 > WriteImageType;
>   typedef itk::RescaleIntensityImageFilter<
>                OutputImageType, WriteImageType > RescaleFilterType;
>   RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
>
>   rescaler->SetOutputMinimum(   0 );
>   rescaler->SetOutputMaximum( 255 );
>
>   typedef itk::ImageFileWriter< WriteImageType >  WriterType;
>   WriterType::Pointer writer = WriterType::New();
>   writer->SetFileName( argv[2] );
>
>   // Software Guide : BeginCodeSnippet
>   rescaler->SetInput( filter->GetOutput() );
>   writer->SetInput( rescaler->GetOutput() );
>   writer->Update();
>
>   return EXIT_SUCCESS;
> }
>
> BEST REGARDS
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090728/d207020e/attachment-0001.htm>


More information about the Insight-users mailing list