Hello,<br> I have the followin code from itk-manual to run OtsuMultipleThresholdImageFilter. What must I type in the command window to run the project?<br>Thanks in advance<br><br>////////////  code//////////////<br><br><br>
#include &quot;itkOtsuMultipleThresholdsCalculator.h&quot;<br><br><br>#include &quot;itkImage.h&quot;<br>#include &quot;itkImageFileReader.h&quot;<br>#include &quot;itkImageFileWriter.h&quot;<br>#include &quot;itkScalarImageToHistogramGenerator.h&quot;<br>
#include &quot;itkBinaryThresholdImageFilter.h&quot;<br>#include &quot;itkNumericTraits.h&quot;<br><br>#include &lt;stdio.h&gt;<br>int main( int argc, char * argv[] )<br>{<br>  if( argc &lt; 5 )<br>    {<br>    std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; argv[0];<br>
    std::cerr &lt;&lt; &quot; inputImageFile outputImageFileBase &quot;;  <br>    std::cerr &lt;&lt; &quot;  outputImageFileExtension numberOfThresholdsToCalculate &quot;  &lt;&lt; std::endl;  <br>    return EXIT_FAILURE;<br>
    }<br>  <br><br>  typedef  unsigned short  InputPixelType;<br>  typedef  unsigned char   OutputPixelType;<br>  <br>  typedef itk::Image&lt; InputPixelType,  3 &gt;   InputImageType;<br>  typedef itk::Image&lt; OutputPixelType, 3 &gt;   OutputImageType;<br>
  <br><br>  typedef itk::Statistics::ScalarImageToHistogramGenerator&lt; <br>  InputImageType &gt; <br>    ScalarImageToHistogramGeneratorType;<br><br>  typedef ScalarImageToHistogramGeneratorType::HistogramType    HistogramType;<br>
<br>  typedef itk::OtsuMultipleThresholdsCalculator&lt; HistogramType &gt;   CalculatorType;<br><br><br>  typedef itk::ImageFileReader&lt; InputImageType &gt;  ReaderType;<br>  typedef itk::ImageFileWriter&lt; OutputImageType &gt;  WriterType;<br>
<br><br>  typedef itk::BinaryThresholdImageFilter&lt; <br>  InputImageType, OutputImageType &gt;  FilterType;<br><br>  ScalarImageToHistogramGeneratorType::Pointer scalarImageToHistogramGenerator = <br>    ScalarImageToHistogramGeneratorType::New();<br>
<br>  CalculatorType::Pointer calculator = CalculatorType::New();<br>  FilterType::Pointer filter = FilterType::New();<br><br><br>  ReaderType::Pointer reader = ReaderType::New();<br>  WriterType::Pointer writer = WriterType::New();<br>
  <br><br>  scalarImageToHistogramGenerator-&gt;SetNumberOfBins( 128 );<br>  calculator-&gt;SetNumberOfThresholds( atoi( argv[4] ) );<br><br>  const OutputPixelType outsideValue = 0;<br>  const OutputPixelType insideValue = 255;<br>
<br>  filter-&gt;SetOutsideValue( outsideValue );<br>  filter-&gt;SetInsideValue(  insideValue  );<br><br><br>  reader-&gt;SetFileName( argv[1] );<br><br>  <br>  scalarImageToHistogramGenerator-&gt;SetInput( reader-&gt;GetOutput() );<br>
  calculator-&gt;SetInputHistogram( scalarImageToHistogramGenerator-&gt;GetOutput() );<br>  filter-&gt;SetInput( reader-&gt;GetOutput() );<br>  writer-&gt;SetInput( filter-&gt;GetOutput() );<br>  <br>  try<br>    { <br>    reader-&gt;Update();<br>
    }<br>  catch( itk::ExceptionObject &amp; excp )<br>    {<br>    std::cerr &lt;&lt; &quot;Exception thrown while reading image&quot; &lt;&lt; excp &lt;&lt; std::endl;<br>    }<br>  scalarImageToHistogramGenerator-&gt;Compute();<br>
  <br>  try<br>    { <br>    calculator-&gt;Update();<br>    }<br>  catch( itk::ExceptionObject &amp; excp )<br>    {<br>    std::cerr &lt;&lt; &quot;Exception thrown &quot; &lt;&lt; excp &lt;&lt; std::endl;<br>    }<br><br>
 <br>  const CalculatorType::OutputType &amp;thresholdVector = calculator-&gt;GetOutput(); <br>  CalculatorType::OutputType::const_iterator itNum = thresholdVector.begin();<br>  <br><span style="background-color: rgb(255, 255, 51);">  std::string outputFileBase = argv[2];</span><br>
  std::string outputFile;<br>  <br>  InputPixelType lowerThreshold = 0;<br>  InputPixelType upperThreshold;<br><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">  std::string format = argv[2];</span><br>
    <br>  char outputFilename[1000];<br>  outputFile = outputFileBase + &quot;%03d.&quot;;<br>  <span style="background-color: rgb(255, 255, 51);">outputFile += argv[3];   // filename extension</span><br><br>         <br>
  for(; itNum &lt; thresholdVector.end(); itNum++) <br>    {<br>    std::cout &lt;&lt; &quot;OtsuThreshold[&quot;<br>              &lt;&lt; (int)(itNum - thresholdVector.begin())<br>              &lt;&lt; &quot;] = &quot; <br>
              &lt;&lt; static_cast&lt;itk::NumericTraits&lt;CalculatorType::MeasurementType&gt;::PrintType&gt;(*itNum) <br>              &lt;&lt; std::endl;  <br><br>    <br>    upperThreshold = static_cast&lt;InputPixelType&gt;(*itNum);<br>
    <br>    filter-&gt;SetLowerThreshold( lowerThreshold );<br>    filter-&gt;SetUpperThreshold( upperThreshold );<br><br>    lowerThreshold = upperThreshold;<br><br>    sprintf (outputFilename, outputFile.c_str(), (itNum - thresholdVector.begin()));<br>
    writer-&gt;SetFileName( outputFilename );<br>    <br><br>    try<br>      { <br>      writer-&gt;Update(); <br>      }<br>    catch( itk::ExceptionObject &amp; excp )<br>      {<br>      std::cerr &lt;&lt; &quot;Exception thrown &quot; &lt;&lt; excp &lt;&lt; std::endl;<br>
      }<br>  <br>    }<br><br>  upperThreshold = itk::NumericTraits&lt;InputPixelType&gt;::max();<br>  filter-&gt;SetLowerThreshold( lowerThreshold );<br>  filter-&gt;SetUpperThreshold( upperThreshold );<br>  <br>  sprintf (outputFilename, outputFile.c_str(), (thresholdVector.size() ));<br>
  writer-&gt;SetFileName( outputFilename );<br>    <br>  try<br>    { <br>    writer-&gt;Update(); <br>    }<br>  catch( itk::ExceptionObject &amp; excp )<br>    {<br>    std::cerr &lt;&lt; &quot;Exception thrown &quot; &lt;&lt; excp &lt;&lt; std::endl;<br>
    }<br><br><br>  return EXIT_SUCCESS;<br>}<br><br><br>