<DIV>Can anyone tell me what's wrong with the code? It gave me a black output image file. I try reading a dicom file and output a "png" file. </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> typedef unsigned char InternalPixelType;<BR> typedef float floatPixelType;<BR> const unsigned int Dimension = 2;<BR> <BR> typedef itk::Image< InternalPixelType, Dimension > InternalImageType;<BR> typedef unsigned char OutputPixelType;<BR> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<BR> typedef itk::Image<floatPixelType, Dimension > floatImageType; </DIV>
<DIV> typedef itk::CastImageFilter< InternalImageType, floatImageType > CastingToFloatType;<BR> CastingToFloatType::Pointer caster = CastingToFloatType::New();<BR> typedef itk::CastImageFilter<floatImageType, OutputImageType> CastingToCharType;<BR> CastingToCharType::Pointer caster2 = CastingToCharType::New();</DIV>
<DIV><BR> typedef itk::ImageFileReader< InternalImageType > ReaderType;<BR> typedef itk::ImageFileWriter< OutputImageType > WriterType;</DIV>
<DIV> ReaderType::Pointer reader = ReaderType::New();<BR> WriterType::Pointer writer = WriterType::New();<BR> reader->SetFileName( argv[1] );<BR> writer->SetFileName( argv[2] );</DIV>
<DIV><BR> typedef itk::CurvatureFlowImageFilter< floatImageType, floatImageType > CurvatureFlowImageFilterType;<BR> CurvatureFlowImageFilterType::Pointer smoothing = <BR> CurvatureFlowImageFilterType::New();</DIV>
<DIV> typedef itk::ConnectedThresholdImageFilter< floatImageType, floatImageType > ConnectedFilterType;<BR> ConnectedFilterType::Pointer connectedThreshold = ConnectedFilterType::New();</DIV>
<DIV> caster->SetInput( reader->GetOutput() );<BR> smoothing->SetInput( caster->GetOutput() );<BR> connectedThreshold->SetInput( smoothing->GetOutput() );<BR> caster2->SetInput( connectedThreshold->GetOutput() );<BR> writer->SetInput( caster2->GetOutput() );</DIV>
<DIV> smoothing->SetNumberOfIterations( 5 );<BR> smoothing->SetTimeStep( 0.125 );</DIV>
<DIV> const InternalPixelType lowerThreshold = atof( argv[5] );<BR> const InternalPixelType upperThreshold = atof( argv[6] );</DIV>
<DIV> <BR> connectedThreshold->SetLower( lowerThreshold );<BR> connectedThreshold->SetUpper( upperThreshold );</DIV>
<DIV><BR> connectedThreshold->SetReplaceValue( 255 );</DIV>
<DIV> InternalImageType::IndexType index;<BR> <BR> index[0] = atoi( argv[3] );<BR> index[1] = atoi( argv[4] );</DIV>
<DIV><BR> connectedThreshold->SetSeed( index );</DIV>
<DIV> try<BR> {<BR> writer->Update();<BR> }<BR> catch( itk::ExceptionObject & excep )<BR> {<BR> std::cerr << "Exception caught !" << std::endl;<BR> std::cerr << excep << std::endl;<BR> }<BR> <BR> </DIV>
<DIV> return 0;<BR>}<BR></DIV><p><br><hr size=1>Post your free ad now! <a href="http://ca.personals.yahoo.com/"><b>Yahoo! Canada Personals</b></a><br>