Hi ITK users,<br><br>I'm attempting to run fuzzy connectedness segmentation on a RGB image. Based on ITK documentation examples, I have compiled the code and build the executable but when I run it the program aborts and the following error message it is displayed:<br><br>.../vnl_matrix.txx : 1184: matrix has non-finite elements<br><br>Any suggestion to fix the problem?.<br><br>Here, it is the code:<br><br><br><br>#include "itkVectorConfidenceConnectedImageFilter.h"<br>#include "itkSimpleFuzzyConnectednessRGBImageFilter.h"<br><br><br>#include "itkImage.h"<br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br>#include "itkVector.h"<br>#include "itkArray2D.h"<br><br><br>int main( int argc, char *argv[] )<br>{<br> if( argc < 7 )<br> {<br> std::cerr << "Missing Parameters " << std::endl;<br> std::cerr << "Usage: " << argv[0];<br>
std::cerr << " inputImage outputImage outputmap seedX seedY multiplier " << std::endl;<br> return 1;<br> }<br><br> typedef unsigned char PixelComponentType;<br> const unsigned char VDim = 3;<br> typedef itk::Vector< PixelComponentType, VDim > InputPixelType;<br> const unsigned int Dimension = 2;<br> typedef itk::Image< InputPixelType, Dimension > InputImageType;<br><br> typedef unsigned char OutputPixelType;<br> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br><br> <br>
typedef itk::VectorConfidenceConnectedImageFilter< InputImageType, <br> OutputImageType > ConnectedFilterType;<br> <br><br> ConnectedFilterType::Pointer confidenceConnected = ConnectedFilterType::New();<br><br> typedef itk::SimpleFuzzyConnectednessRGBImageFilter< InputImageType, OutputImageType > FuzzySegmentationFilterType;<br> <br> FuzzySegmentationFilterType::Pointer fuzzysegmenter = FuzzySegmentationFilterType::New();<br><br> typedef FuzzySegmentationFilterType::FuzzySceneType FuzzySceneType; <br><br> typedef itk::ImageFileReader< InputImageType > ReaderType;<br> typedef itk::ImageFileWriter< OutputImageType > WriterType;<br>
typedef itk::ImageFileWriter< FuzzySceneType > FuzzyWriterType;<br><br><br> ReaderType::Pointer reader = ReaderType::New();<br> WriterType::Pointer writer = WriterType::New();<br><br> FuzzyWriterType::Pointer fwriter = FuzzyWriterType::New();<br><br> reader->SetFileName( argv[1] );<br> writer->SetFileName( argv[2] ); <br> fwriter->SetFileName( argv[3] );<br><br> InputImageType::IndexType index;<br><br> index[0] = atoi(argv[4]);<br> index[1] = atoi(argv[5]);<br><br><br> confidenceConnected->SetInput( reader->GetOutput() );<br><br> WriterType::Pointer confidenceWriter = WriterType::New();<br> confidenceWriter->SetInput( confidenceConnected->GetOutput() );<br> confidenceWriter->SetFileName("confConPre.png");<br> confidenceWriter->Update();<br><br> <br> fuzzysegmenter->SetInput( reader->GetOutput()
);<br> <br> const double multiplier = atof( argv[6] );<br><br> confidenceConnected->SetMultiplier( multiplier );<br><br> const unsigned int iterations = 2;<br> <br> confidenceConnected->SetNumberOfIterations( iterations );<br><br> confidenceConnected->SetReplaceValue( 255 );<br><br> confidenceConnected->SetSeed( index );<br> <br> //confidenceConnected->AddSeed( index );<br><br> confidenceConnected->SetInitialNeighborhoodRadius( 3 );<br><br> typedef ConnectedFilterType::MeanVectorType MeanVectorType; <br> <br> const MeanVectorType & mean = confidenceConnected->GetMean();<br><br> typedef ConnectedFilterType::CovarianceMatrixType CovarianceMatrixType; <br> <br> const CovarianceMatrixType & covariance = confidenceConnected->GetCovariance();<br> <br> std::cout
<< "Covariance matrix = " << std::endl;<br> std::cout << covariance << std::endl;<br> <br> fuzzysegmenter->SetObjectSeed( index );<br> <br> const double * mean1 = mean.data_block();<br><br> const double * cov1 = covariance.data_block();<br><br> double ccov[3][3]; <br> <br> double mmean[3];<br> <br> int z=0;<br> for (int x=0; x<3; ++x)<br> for (int y=0; y<3; ++y)<br> {<br> ccov[x][y]= cov1[z];<br> ++z;<br> }<br><br> <br> for (int i=0; i<3; ++i)<br> mmean[i]= mean1[i];<br><br> fuzzysegmenter->SetMean( mmean ); <br> fuzzysegmenter->SetVariance( ccov );<br> fuzzysegmenter->SetThreshold( 0.5 );<br> <br> writer->SetInput( fuzzysegmenter->GetOutput() );<br> <br> fwriter->SetInput(
fuzzysegmenter->GetFuzzyScene() );<br> <br><br> try<br> {<br> fuzzysegmenter->Update();<br> writer->Update();<br> fwriter->Update();<br> }<br> catch( itk::ExceptionObject & excep )<br> {<br> std::cerr << "Exception caught !" << std::endl;<br> std::cerr << excep << std::endl;<br> }<br><br><br> return 0;<br>}<br><br><p> 
<hr size=1>No need to miss a message. <a href="http://us.rd.yahoo.com/evt=43910/*http://mobile.yahoo.com/mail
">Get email on-the-go </a><br>with Yahoo! Mail for Mobile. <a href="http://us.rd.yahoo.com/evt=43910/*http://mobile.yahoo.com/mail
">Get started.</a>