Hi,<br><div class="gmail_quote">I'm trying to use ConnectedThresholdImageFilter.cxx on a 3D image (a .mhd file). I inserted one seed point with 3 coordinates an tried different values of threshold. When I run the program, I save the output results in a .mhd file but i obtain only a black image. So i don't obtain a true segmentation. <br>
The code is this:<br><br><br>#include "itkConnectedThresholdImageFilter.h"<br><br><br>#include "itkImage.h"<br>#include "itkCastImageFilter.h"<br>#include "itkCurvatureFlowImageFilter.h"<br>
#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br><br><br>int main( int argc, char *argv[])<br>{<br>if( argc < 8 )<br> {<br> std::cerr << "Missing Parameters " << std::endl;<br>
std::cerr << "Usage: " << argv[0];<br> std::cerr << " inputImage outputImage seedX seedY seedZ lowerThreshold upperThreshold" << std::endl;<br> return 1;<br> }<br>
<br> typedef float InternalPixelType;<br> const unsigned int Dimension = 3;<br> typedef itk::Image< InternalPixelType, Dimension > InternalImageType;<br><br><br> typedef unsigned char OutputPixelType;<br>
typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br> typedef itk::CastImageFilter< InternalImageType, OutputImageType ><br> CastingFilterType;<br>
CastingFilterType::Pointer caster = CastingFilterType::New();<br> <br><br> typedef itk::ImageFileReader< InternalImageType > ReaderType;<br> typedef itk::ImageFileWriter< OutputImageType > WriterType;<br>
<br> ReaderType::Pointer reader = ReaderType::New();<br> WriterType::Pointer writer = WriterType::New();<br><br> reader->SetFileName( argv[1] );<br> writer->SetFileName( argv[2] );<br> typedef itk::CurvatureFlowImageFilter< InternalImageType, InternalImageType ><br>
CurvatureFlowImageFilterType;<br><br> CurvatureFlowImageFilterType::Pointer smoothing = <br> CurvatureFlowImageFilterType::New();<br> <br> typedef itk::ConnectedThresholdImageFilter< InternalImageType, <br>
InternalImageType > ConnectedFilterType;<br> <br> ConnectedFilterType::Pointer connectedThreshold = ConnectedFilterType::New();<br> <br><br> smoothing->SetInput( reader->GetOutput() );<br>
connectedThreshold->SetInput( smoothing->GetOutput() );<br> caster->SetInput( connectedThreshold->GetOutput() );<br> writer->SetInput( caster->GetOutput() );<br><br> smoothing->SetNumberOfIterations( 5 );<br>
smoothing->SetTimeStep( 0.125 );<br><br> const InternalPixelType lowerThreshold = atof( argv[6] );<br> const InternalPixelType upperThreshold = atof( argv[7] );<br><br> connectedThreshold->SetLower( lowerThreshold );<br>
connectedThreshold->SetUpper( upperThreshold );<br><br> connectedThreshold->SetReplaceValue( 255 );<br> <br> InternalImageType::IndexType index;<br> index[0] = atoi( argv[3] );<br> index[1] = atoi( argv[4] );<br>
index[2] = atoi( argv[5] );<br> connectedThreshold->SetSeed( index );<br><br> //InternalImageType::IndexType index1;<br> //index1[0] = atoi( argv[3] );<br> //index1[1] = atoi( argv[4] );<br> //connectedThreshold->AddSeed( index1 );<br>
<br> 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>return 0;<br>}<br><br><br>Can someone explain me if this is a problem of thresholding or a problem of image format?! I don't really know what to do.<br>Thanks,<br><font color="#888888">Marco<br>
</font></div><br>