[Insight-users] Problem with itkAddImageFilter

Anders Almås andersal at stud . ntnu . no
Thu, 30 Oct 2003 16:10:00 +0100 (CET)


Hi again!

Here follows my type definitions:

const unsigned int Dimension = 2;
typedef unsigned short PixelType;
typedef itk::Image<PixelType,Dimension> ImageType;

typedef itk::ImageFileReader<ImageType> ReaderType;
typedef itk::ImageFileWriter<ImageType> WriterType;
typedef itk::AddImageFilter<ImageType,ImageType,ImageType> addFilterType;

This is all my typedefs.. the files  which I use are png's with only 0 and
255 as pixel values...

Anders


-------------------------------------------------------------------------------
Navn:   Anders Almås
E-post: andersal at stud . ntnu . no
Tlf:    90550374
-------------------------------------------------------------------------------
























...............................................................................

Anders Almås            Min hjemmeside:

7230 Trondheim          http://stud . ntnu . no/~andersal/

...............................................................................



On Thu, 30 Oct 2003, Luis Ibanez wrote:

>
> Hi Anders,
>
>
> Please post the type definitions that you used for adding
> these two images as well as the types you used for saving
> the image into a file.
>
>
> ---
>
>
> You should be doing something like
>
> typedef itk::Image< unsigned char,  3 >   InputImageType;
> typedef itk::Image< unsigned short, 3 >   OutputImageType;
>
> // Note that the output image type requires a larger
> // dynamic range (unsigned short) in order to hold
> // the values resulting from the addition.
>
> typedef itk::AddImageFilter<
>                       InputImageType,
>                       InputImageType,
>                       OutputImageType   > AdderType;
>
> typedef itk::Image< unsigned char, 3 >   WriteImageType;
>
> typedef itk::RescaleIntensityImageFilter<
>                                    OutputImageType,
>                                    WriteImageType
>                                           >   RescalerType;
>
> typedef itk::ImageFileWriter< WriteImageType > WriterType;
>
> // Note that the writer type is declared using 8 bits
> // and the rescaler filter will renormalize the
> // intensity levels of the sum in order to fit in 8 bits again.
> // (after the addition the data was potentially in 9 bits.)
>
> AdderType::Pointer adder = AdderType::New();
>
> RescalerType::Pointer rescaler = RescalerType::New();
>
> WriterType::Pointer writer = WriterType::New();
>
> adder->SetInput1( image1 );
> adder->SetInput2( image2 );
>
> rescaler->SetInput( adder->GetOutput() );
> rescaler->SetOutputMinimum(   0 );
> rescaler->SetOutputMaximum( 255 );
>
> writer->SetInput( rescaler->GetOutput() );
>
> writer->SetFileName("sum.png");
>
> writer->Update();
>
>
> ----------
>
>
> Note that it is a common mistake to save images with
> intesities in the 8bit range as images of 16bits.
> This usually happens when using PNG as file format.
> The resulting image looks black when seen with a
> viewer that doens't normalize the intensity levels.
>
> The ImageViewer application available in InsightApplications
> performs a normalization of intensity levels. (you may want
> to use this viewer...)
>
>
>
> Regards,
>
>
>    Luis
>
>
>
> -----------------------
> Anders Almås wrote:
> > Hi!
> > I am new to ITK. I have a question about itkAddImageFilter
> >
> > I  try to add two binary images together but my result is a  black imag=
e.
> > I have managed to subtract two images.. I thought mybe I got out of ran=
ge
> > when two pixles with intensity of 255 was added, but I  implemented als=
o a
> > rescale intensity image filter but the same result occured..
> >
> > Fo anyone have some suggestions?
> >
> > Regards
> >
> > Anders
> >
> > -----------------------------------------------------------------------=
--------
> > Navn:   Anders Almås
> > E-post: andersal at stud . ntnu . no
> > Tlf:    90550374
> > -----------------------------------------------------------------------=
--------
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > .......................................................................=
........
> >
> > Anders Almås            Min hjemmeside:
> >
> > 7230 Trondheim          http://stud . ntnu . no/~andersal/
> >
> > .......................................................................=
........
> >
> >
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk . org
> > http://www . itk . org/mailman/listinfo/insight-users
> >
>
>
>
>