<DIV>
<FORM name=frmAddAddrs action=http://address.mail.yahoo.com/yab/us?v=YM&.rand=58728&A=m&simp=1 method=post><TT>Hi all,<BR><BR>I am running ITK 1.8.1 and I have been trying to use<BR>the SecondDerivateRecursiveGaussianImageFilter found<BR>at Examples\Filtering\SecondDerivativeRecursiveGaussianImageFilter.cxx<BR>on a large volume (>= 700x700x700) but it always<BR>crashes the first time it reaches the line: <BR><BR>gc->Update;<BR><BR>The only modification I have made to the example is<BR>that the input and output pixel type is short instead<BR>of float. It runs fine on smaller volumes but crashes<BR>on anything bigger than 700x700x700. <BR><BR>I am posting the code as found in examples with the<BR>float parameter changed to short. I have also posted<BR>some code below it that creates volumes with a sphere<BR>in it. The argument list I used to create my test<BR>volume was: BigSphere.mhd 700 700 700 200 200 200 100.<BR>The first parameter is the name, the next three
are<BR>the dimensions of the volume, the next three are the<BR>center of the sphere and the last one is the radius of<BR>the sphere. <BR><BR>Does anyone have any ideas what might be causing this?<BR><BR>Thanks!<BR><BR>Robert </TT></FORM>
<DIV id=message>
<DIV><PRE><TT>Volume Creator:</TT></PRE><PRE><TT>#include "itkImage.h"<BR>#include "itkImageFileReader.h"<BR>#include "itkImageFileWriter.h"<BR>#include "itkRecursiveGaussianImageFilter.h"<BR>#include "itkImageDuplicator.h"<BR>#include <string.h><BR>#include <iostream><BR>#include <fstream><BR>#include "itkCastImageFilter.h"<BR>#include "itkRescaleIntensityImageFilter.h"<BR>#include <cmath><BR>using namespace std;</TT></PRE><TT><PRE><BR>// Function prototypes<BR>int CastUCharTOShortVol( const char *, const char * );</PRE><PRE>int main( int argc, char ** argv)<BR>{<BR> char * inputImageName = argv[1];<BR> char * outputImageName = argv[2];<BR> <BR> CastUCharTOShortVol(inputImageName, outputImageName );</PRE><PRE> return 0;<BR>}</PRE><PRE>int CastUCharTOShortVol( const char * inputFile, const char *
outputFile )<BR>{<BR> typedef unsigned char PixelType;<BR> typedef short OutPixelType;<BR> const unsigned int Dimension = 3;</PRE><PRE> // Define the image type and dimensions<BR> typedef itk::Image< PixelType, Dimension > ImageType;<BR> typedef itk::Image< OutPixelType, Dimension > OutputImageType;</PRE><PRE> // Define typedefs for the readers and writers<BR> typedef itk::ImageFileReader< ImageType > ReaderType;<BR> typedef itk::ImageFileWriter< OutputImageType > WriterType;<BR> typedef itk::CastImageFilter<ImageType, OutputImageType > CastToShortFilterType;<BR> typedef itk::RescaleIntensityImageFilter< ImageType, OutputImageType > RescaleFilterType;</PRE><PRE> // Initialize
pointers for the readers and writers<BR> ReaderType::Pointer reader = ReaderType::New();<BR> WriterType::Pointer writer = WriterType::New();<BR> CastToShortFilterType::Pointer castToShortFilter = CastToShortFilterType::New();<BR> RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New();<BR> <BR> // Set the input and output file names for the reader and writer<BR> reader->SetFileName( inputFile );<BR> writer->SetFileName( outputFile );</PRE><PRE> // We can now access the input in the variable 'image'<BR> ImageType::Pointer image = reader->GetOutput();</PRE><PRE> // Convert the image to float<BR> castToShortFilter->SetInput( image );<BR>// rescaleFilter->SetInput(image);<BR>// rescaleFilter->SetOutputMinimum( 0);<BR>// rescaleFilter->SetOutputMaximum(255); <BR> <BR> // Set the input of the writer as the output of castToFloatFilter<BR>
writer->SetInput ( castToShortFilter->GetOutput() );</PRE><PRE> // Update the writer to send the image to the file specified by outFileName <BR> // and outDataFileName<BR> try <BR> { <BR> writer->Update(); <BR> } <BR> catch( itk::ExceptionObject & err ) <BR> { <BR> std::cout << "ExceptionObject caught !" << std::endl; <BR> std::cout << err << std::endl; <BR> return -1;<BR> }</PRE><PRE> return 0;<BR>}</PRE>SecondDerivativeRecursiveGaussianImageFilter<PRE>#include "itkRecursiveGaussianImageFilter.h"<BR>#include "itkImageFileReader.h"<BR>#include "itkImageFileWriter.h"<BR>#include "itkImageDuplicator.h"<BR>#include "itkImage.h"<BR>#include <string></PRE><PRE><BR>int main(int argc, char * argv [] )<BR>{</PRE><PRE> if( argc < 3 )<BR>
{<BR> std::cerr << "Usage: " << std::endl;<BR> std::cerr << "SecondDerivativeRecursiveGaussianImageFilter inputImage outputPrefix [sigma] " << std::endl;<BR> return -1;<BR> }</PRE><PRE> typedef short PixelType;<BR> typedef short OutputPixelType;</PRE><PRE> const unsigned int Dimension = 3;</PRE><PRE> typedef itk::Image< PixelType, Dimension > ImageType;<BR> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<BR> <BR> typedef itk::ImageFileReader< ImageType > ReaderType;<BR> typedef itk::ImageFileWriter< OutputImageType > WriterType;</PRE><PRE> typedef
itk::ImageDuplicator< OutputImageType > DuplicatorType;</PRE><PRE> typedef itk::RecursiveGaussianImageFilter< <BR> ImageType, <BR> ImageType > FilterType;</PRE><PRE> ReaderType::Pointer reader = ReaderType::New();<BR> WriterType::Pointer writer = WriterType::New();</PRE><PRE> DuplicatorType::Pointer duplicator = DuplicatorType::New();</PRE><PRE> reader->SetFileName( argv[1] );<BR> <BR> std::string outputPrefix = argv[2];<BR> std::string
outputFileName;</PRE><PRE> try<BR> {<BR> reader->Update();<BR> }<BR> catch( itk::ExceptionObject & excp )<BR> {<BR> std::cerr << "Problem reading the input file" << std::endl;<BR> std::cerr << excp << std::endl;<BR> return -1;<BR> }</PRE><PRE> FilterType::Pointer ga = FilterType::New();<BR> FilterType::Pointer gb = FilterType::New();<BR> FilterType::Pointer gc = FilterType::New();</PRE><PRE> ga->SetDirection( 0 );<BR> gb->SetDirection( 1 );<BR> gc->SetDirection( 2 );</PRE><PRE> if( argc > 3 )<BR> {<BR> const float sigma = atof( argv[3] );<BR> ga->SetSigma( sigma );<BR> gb->SetSigma( sigma );<BR> gc->SetSigma( sigma );<BR>
}</PRE><PRE> ga->SetZeroOrder();<BR> gb->SetZeroOrder();<BR> gc->SetSecondOrder();</PRE><PRE> ImageType::Pointer inputImage = reader->GetOutput();</PRE><PRE> ga->SetInput( inputImage );<BR> gb->SetInput( ga->GetOutput() );<BR> gc->SetInput( gb->GetOutput() );</PRE><PRE> duplicator->SetInputImage( gc->GetOutput() );</PRE><PRE><BR> gc->Update(); <BR> duplicator->Update();</PRE><PRE> ImageType::Pointer Izz = duplicator->GetOutput();</PRE><PRE> writer->SetInput( Izz );<BR> outputFileName = outputPrefix + "-Izz.mhd";<BR> writer->SetFileName( outputFileName.c_str() );<BR> writer->Update();</PRE><PRE> gc->SetDirection( 1 ); // gc now works along Y<BR> gb->SetDirection( 2 ); // gb now works along Z</PRE><PRE> gc->Update();<BR> duplicator->Update();</PRE><PRE> ImageType::Pointer Iyy =
duplicator->GetOutput();</PRE><PRE> writer->SetInput( Iyy );<BR> outputFileName = outputPrefix + "-Iyy.mhd";<BR> writer->SetFileName( outputFileName.c_str() );<BR> writer->Update();</PRE><PRE><BR> gc->SetDirection( 0 ); // gc now works along X<BR> ga->SetDirection( 1 ); // ga now works along Y</PRE><PRE> gc->Update();<BR> duplicator->Update();</PRE><PRE> ImageType::Pointer Ixx = duplicator->GetOutput();</PRE><PRE> writer->SetInput( Ixx );<BR> outputFileName = outputPrefix + "-Ixx.mhd";<BR> writer->SetFileName( outputFileName.c_str() );<BR> writer->Update();</PRE><PRE><BR> ga->SetDirection( 0 );<BR> gb->SetDirection( 1 );<BR> gc->SetDirection( 2 );</PRE><PRE> ga->SetZeroOrder();<BR> gb->SetFirstOrder();<BR> gc->SetFirstOrder();</PRE><PRE> gc->Update();<BR>
duplicator->Update();</PRE><PRE> ImageType::Pointer Iyz = duplicator->GetOutput();</PRE><PRE> writer->SetInput( Iyz );<BR> outputFileName = outputPrefix + "-Iyz.mhd";<BR> writer->SetFileName( outputFileName.c_str() );<BR> writer->Update();</PRE><PRE><BR> ga->SetDirection( 1 );<BR> gb->SetDirection( 0 );<BR> gc->SetDirection( 2 );</PRE><PRE> ga->SetZeroOrder();<BR> gb->SetFirstOrder();<BR> gc->SetFirstOrder();</PRE><PRE> gc->Update();<BR> duplicator->Update();</PRE><PRE> ImageType::Pointer Ixz = duplicator->GetOutput();</PRE><PRE> writer->SetInput( Ixz );<BR> outputFileName = outputPrefix + "-Ixz.mhd";<BR> writer->SetFileName( outputFileName.c_str() );<BR> writer->Update();</PRE><PRE> ga->SetDirection( 2 );<BR> gb->SetDirection( 0 );<BR> gc->SetDirection( 1 );</PRE><PRE>
ga->SetZeroOrder();<BR> gb->SetFirstOrder();<BR> gc->SetFirstOrder();</PRE><PRE> gc->Update();<BR> duplicator->Update();</PRE><PRE> ImageType::Pointer Ixy = duplicator->GetOutput();</PRE><PRE> writer->SetInput( Ixy );<BR> outputFileName = outputPrefix + "-Ixy.mhd";<BR> writer->SetFileName( outputFileName.c_str() );<BR> writer->Update();</PRE><PRE> // Software Guide : EndCodeSnippet<BR> <BR>return 0;<BR>}</PRE></TT></DIV></DIV></DIV><p>
        
                <hr size=1>Do you Yahoo!?<br>
Check out the new Yahoo! Front Page. <a href="http://www.yahoo.com">www.yahoo.com</a>