[Insight-users] same piece of code produces different results in Mac and Linux

Feng Ding carlding at gmail.com
Wed Apr 18 00:34:28 EDT 2007


Dear ITK users,

I tested a simple canny edge extraction program using ITK  3.2.0 in
both Mac OS (with gcc 4.0.1) and Ubuntu Linux (with gcc 4.1.2). The
program gave me different edge images on these two platforms. Anyone
met this before?

The code is as follows,

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkCastImageFilter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "itkCannyEdgeDetectionImageFilter.h"

typedef unsigned char PixelType;
typedef float InternalPixelType;
typedef itk::Image< PixelType, 2 > ImageType;
typedef itk::Image< InternalPixelType, 2 > InternalImageType;
typedef itk::CannyEdgeDetectionImageFilter< InternalImageType,
InternalImageType > CannyFilterType;
typedef itk::ImageFileReader< ImageType > ReaderType;
typedef itk::ImageFileWriter< ImageType > WriterType;
typedef itk::CastImageFilter< ImageType, InternalImageType > FCasterType;
typedef itk::RescaleIntensityImageFilter< InternalImageType, ImageType
> BCasterType;

int main( int argc, char *argv[] )
{
	if( argc < 3 )
        {
		std::cerr << "Missing Parameters " << std::endl;
		std::cerr << "Usage: " << argv[0];
		std::cerr << " inputImage  outputImage" << std::endl;
		return 1;
        }
	
	ReaderType::Pointer reader = ReaderType::New();
	WriterType::Pointer writer = WriterType::New();
	
	FCasterType::Pointer fCaster = FCasterType::New();
	BCasterType::Pointer bCaster = BCasterType::New();
	
	CannyFilterType::Pointer canny = CannyFilterType::New();
	
	reader->SetFileName( argv[1] );
	fCaster->SetInput( reader->GetOutput() );
	
	canny->SetInput( fCaster->GetOutput() );
        canny->SetVariance( 1.5 );
        canny->SetUpperThreshold( 1.5 );
	
	bCaster->SetOutputMinimum( 0 );
        bCaster->SetOutputMaximum( 255 );		
	bCaster->SetInput( canny->GetOutput() );
	
	writer->SetInput( bCaster->GetOutput() );
	writer->SetFileName( argv[2] );
	writer->Update();

}

Best regards,
DING Feng


More information about the Insight-users mailing list