[Insight-users] GradientMagnitudeImageFilter produce zero value image
Fucang Jia
jiafucang@hotmail.com
Fri, 06 Dec 2002 15:41:41 +0800
Hi, everyone,
When I try use the example in the ITK tutorial, I can not get the right
image as expected, the output image is all zero, so all black. I try to use
rescale filters, but it seems that there is not rescaling problem. I do not
know reason, can anyone tell me the trick? here is the code:
#include "itkImage.h"
#include "itkImageFileWriter.h"
#include "itkImageFileReader.h"
#include "itkPNGImageIO.h"
#include "itkGradientMagnitudeImageFilter.h"
int main( int argc, char **argv ) {
typedef itk::Image<unsigned char, 2> ImageType;
typedef itk::Image<float,2> FloatImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;
typedef itk::ImageFileWriter<ImageType> WriterType;
typedef itk::GradientMagnitudeImageFilter<
ImageType,ImageType> FilterType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
FilterType::Pointer filter = FilterType::New();
reader->SetFileName( argv[1] );
filter->SetInput( reader->GetOutput() );
writer->SetImageIO( itk::PNGImageIO::New() );
writer->SetFileName( argv[2] );
writer->SetInput( filter->GetOutput() );
writer->Update();
return 0;
}
Thanks!
Fucang
_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail