<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV><FONT color=#000000>Hi all,</FONT></DIV>
<DIV><FONT color=#000000> i have try to execute the following code but every time i run the exe it stop working:</FONT></DIV>
<DIV><FONT color=#000000>and the message: a problem caused the program to stop working correctly. windows will close the program and notify you if a solution is available.</FONT></DIV>
<DIV><FONT color=#000000></FONT> </DIV>
<DIV><FONT color=#000000>colud some one try the gode with his .png file</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>the source code:</DIV>
<DIV> </DIV>
<DIV>#<SPAN>ifdef</SPAN></FONT></FONT><FONT size=2> _MSC_VER</DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>#pragma</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>warning</FONT></FONT><FONT size=2> ( </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>disable</FONT></FONT><FONT size=2> : 4786 )</DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>#endif</DIV>
<DIV>#ifdef</FONT></FONT><FONT size=2> __BORLANDC__</DIV></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>
<DIV>#define ITK_LEAN_AND_MEAN</DIV></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>#endif</DIV></FONT></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>
<DIV> </DIV></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2><iostream></DIV></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"itkVectorGradientAnisotropicDiffusionImageFilter.h"</DIV></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"itkVectorGradientMagnitudeImageFilter.h"</DIV></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"itkWatershedImageFilter.h"</DIV></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2><conio.h></DIV></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"itkImageFileReader.h"</DIV></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"itkImageFileWriter.h"</DIV></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"itkVectorCastImageFilter.h"</DIV></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"itkUnaryFunctorImageFilter.h"</DIV></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"itkScalarToRGBPixelFunctor.h"</DIV></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>int</FONT></FONT><FONT size=2> main( </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>int</FONT></FONT><FONT size=2> argc, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>char</FONT></FONT><FONT size=2> *argv[] )</DIV>
<DIV>{</DIV>
<DIV></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>/*if (argc < 8 )</DIV>
<DIV>{</DIV>
<DIV>std::cerr << "Missing Parameters " << std::endl;</DIV>
<DIV>std::cerr << "Usage: " << argv[0];</DIV>
<DIV>std::cerr << " inputImage outputImage conductanceTerm diffusionIterations lowerThreshold outputScaleLevel gradientMode " << std::endl;</DIV>
<DIV>return 1;</DIV>
<DIV>}*/</DIV></FONT></FONT><FONT size=2>
<DIV></DIV>
<DIV></FONT>
<DIV><FONT color=#008000 size=2><FONT color=#008000 size=2></DIV></FONT></FONT><FONT size=2></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::RGBPixel<</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>unsigned</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>char</FONT></FONT><FONT size=2>> RGBPixelType;
<DIV></DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::Image<RGBPixelType, 2> RGBImageType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::Vector<</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>float</FONT></FONT><FONT size=2>, 3> VectorPixelType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::Image<VectorPixelType, 2> VectorImageType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::Image<</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>unsigned</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>long</FONT></FONT><FONT size=2>, 2> LabeledImageType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::Image<</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>float</FONT></FONT><FONT size=2>, 2> ScalarImageType;</DIV>
<DIV></DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::ImageFileReader<RGBImageType> FileReaderType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::VectorCastImageFilter<RGBImageType, VectorImageType> </DIV>
<DIV>CastFilterType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::VectorGradientAnisotropicDiffusionImageFilter<VectorImageType,</DIV>
<DIV>VectorImageType> DiffusionFilterType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::VectorGradientMagnitudeImageFilter<VectorImageType></DIV>
<DIV>GradientMagnitudeFilterType; </DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::WatershedImageFilter<ScalarImageType> WatershedFilterType;</DIV>
<DIV></DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::ImageFileWriter<RGBImageType> FileWriterType;</DIV>
<DIV>FileReaderType::Pointer reader = FileReaderType::New();</DIV>
<DIV>reader->SetFileName(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"V.png"</FONT></FONT><FONT size=2>);</DIV>
<DIV></DIV>
<DIV>CastFilterType::Pointer caster = CastFilterType::New();</DIV>
<DIV></DIV>
<DIV></FONT>
<DIV><FONT color=#008000 size=2><FONT color=#008000 size=2></DIV></FONT></FONT><FONT size=2>
<DIV></DIV>DiffusionFilterType::Pointer diffusion = DiffusionFilterType::New();
<DIV></DIV>
<DIV>diffusion->SetNumberOfIterations( atoi(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"2"</FONT></FONT><FONT size=2>) );</FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// more than 5 will get smother</DIV></FONT></FONT><FONT size=2>
<DIV>diffusion->SetConductanceParameter( atof(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"3"</FONT></FONT><FONT size=2>) );</FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>//usually around 3</DIV></FONT></FONT><FONT size=2>
<DIV>diffusion->SetTimeStep(0.125);</FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// for 3d and 0.25 for2d</FONT></FONT></DIV>
<DIV><FONT color=#008000></FONT> </DIV>
<DIV><FONT color=#008000 size=2><FONT color=#008000 size=2></DIV>
<DIV></FONT></FONT><FONT size=2>GradientMagnitudeFilterType::Pointer </DIV>
<DIV>gradient = GradientMagnitudeFilterType::New();</DIV>
<DIV>gradient->SetUsePrincipleComponents(atoi(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"0"</FONT></FONT><FONT size=2>));</DIV>
<DIV></FONT>
<DIV><FONT color=#008000 size=2><FONT color=#008000 size=2></DIV></FONT></FONT><FONT size=2>WatershedFilterType::Pointer watershed = WatershedFilterType::New();
<DIV></DIV>
<DIV>watershed->SetLevel( atof(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"0.05"</FONT></FONT><FONT size=2>) );</DIV>
<DIV>watershed->SetThreshold( atof(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"1"</FONT></FONT><FONT size=2>) );</DIV>
<DIV></DIV>
<DIV></FONT>
<DIV><FONT color=#008000 size=2><FONT color=#008000 size=2></DIV></FONT></FONT><FONT size=2>
<DIV></DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::Functor::ScalarToRGBPixelFunctor<</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>unsigned</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>long</FONT></FONT><FONT size=2>>
<DIV></DIV>
<DIV>ColorMapFunctorType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::UnaryFunctorImageFilter<LabeledImageType,</DIV>
<DIV>RGBImageType, ColorMapFunctorType> ColorMapFilterType;</DIV>
<DIV>ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New();</DIV>
<DIV></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2></FONT></FONT> </DIV>
<DIV><FONT color=#008000 size=2><FONT color=#008000 size=2> </DIV></FONT></FONT><FONT size=2>
<DIV></DIV>
<DIV>FileWriterType::Pointer writer = FileWriterType::New();</DIV>
<DIV>writer->SetFileName(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"WatershedSegmentation1Output1.png"</FONT></FONT><FONT size=2>);</DIV>
<DIV></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2> </DIV></FONT></FONT><FONT size=2>
<DIV>caster->SetInput(reader->GetOutput());</DIV>
<DIV>diffusion->SetInput(caster->GetOutput());</DIV>
<DIV>gradient->SetInput(diffusion->GetOutput());</DIV>
<DIV>watershed->SetInput(gradient->GetOutput());</DIV>
<DIV>colormapper->SetInput(watershed->GetOutput());</DIV>
<DIV>writer->SetInput(colormapper->GetOutput());</DIV>
<DIV></DIV></FONT><FONT size=2>
<DIV></DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2></FONT></FONT> </DIV><FONT color=#0000ff size=2><FONT color=#0000ff size=2><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<DIV>try</FONT></FONT><FONT size=2><FONT color=#000000> </FONT></DIV>
<DIV> <FONT color=#000000>{ </FONT></DIV>
<DIV><FONT color=#000000> writer->Update();</FONT></DIV>
<DIV><FONT color=#000000> }</FONT></DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>catch</FONT></FONT><FONT size=2> (itk::ExceptionObject &e)</DIV>
<DIV><FONT color=#000000> {</FONT></DIV>
<DIV><FONT color=#000000> std::cerr << e << std::endl;</FONT></DIV>
<DIV><FONT color=#000000> }</FONT></DIV>
<DIV> </DIV>
<DIV></DIV></FONT></FONT></FONT>
<DIV><FONT color=#0000ff size=2><FONT color=#0000ff size=2>return</FONT></FONT><FONT size=2> 0;</DIV>
<DIV>}</DIV></FONT></td></tr></table><br>