Build Simple Functions

Hi, I would like to know what is wrong with this function:

I get :

thanks

Segment_Bone(typename TImage::Pointer input, typename TImage::Pointer output,double bone_threshold_factor_percentage)
| ^~~~~~~~~~~~
template argument deduction/substitution failed:
couldn’t deduce template parameter ‘TImage’

    template <typename TImage>
    void
    Segment_Bone(typename TImage::Pointer input, typename TImage::Pointer output,double bone_threshold_factor_percentage)
    {
        
        using PixelType_Bone_Reader = typename TImage::PixelType;
        constexpr unsigned short Dimension = 3;
        using ImageType_Bone_Reader = itk::Image<TImage, Dimension>;
     
        using RescaleType_Bone      = itk::RescaleIntensityImageFilter<TImage, TImage>;
        using Minimum_Bone_Type     = itk::MinimumMaximumImageFilter<TImage>;
        using Threshold_Bone_Type   = itk::BinaryThresholdImageFilter<TImage, TImage>;

    
      auto Rescale_Bone = RescaleType_Bone::New();
      Rescale_Bone->SetInput(input);
      Rescale_Bone->SetOutputMinimum(-1000);
      Rescale_Bone->SetOutputMaximum(1000);

      auto Minimum_Bone = Minimum_Bone_Type::New();
      Minimum_Bone->SetInput(Rescale_Bone->GetOutput());
      
      const PixelType_Bone_Reader ImageHighestIntensity_Bone = Minimum_Bone->GetMaximum() ;
      Minimum_Bone->Update();

      auto Threshold_Bone = Threshold_Bone_Type::New();
      Threshold_Bone->SetInput(Rescale_Bone->GetOutput());

      const PixelType_Bone_Reader outsideValue_Bone = 0;
      const PixelType_Bone_Reader insideValue_Bone = 255;

          Threshold_Bone->SetOutsideValue(outsideValue_Bone);
          Threshold_Bone->SetInsideValue(insideValue_Bone);


          const PixelType_Bone_Reader lowerThreshold_Bone = (Minimum_Bone->GetMaximum())*bone_threshold_factor_percentage;
          const PixelType_Bone_Reader upperThreshold_Bone = Minimum_Bone->GetMaximum();

          std::cerr << "Lower Threshold for Bones: " <<lowerThreshold_Bone<< "   Upper Threshold for Bones: " <<upperThreshold_Bone<<  std::endl;
          Threshold_Bone->SetLowerThreshold(lowerThreshold_Bone);
          Threshold_Bone->SetUpperThreshold(upperThreshold_Bone);
          Threshold_Bone->Update();
          
          output = Threshold_Bone->GetOutput();
          
          }

in the main program:

  using PixelType_Bone_Reader = signed short;
        using ImageType_Bone_Reader = 
itk::Image<PixelType_Bone_Reader, Dimension>;


        using ReaderType_Bone       = itk::ImageSeriesReader<ImageType_Bone_Reader>;
        using CastFilter_Bone_Type  = itk::CastImageFilter<ImageType_Bone_Reader, ImageType>;        
        using WriterType_Bone       = itk::ImageFileWriter<ImageType>;
 
       auto reader_Bone = ReaderType_Bone::New();
       reader_Bone->SetImageIO(gdcmIO);
       reader_Bone->SetFileNames(filenames);

       auto reader_Bone_2 = ReaderType_Bone::New();
       reader_Bone_2->SetImageIO(gdcmIO);
       reader_Bone_2->SetFileNames(filenames);

       try{reader_Bone->Update();}
       catch (const itk::ExceptionObject & excp)
       {std::cerr << "Exception thrown while writing the image" << std::endl;std::cerr << excp << std::endl;
       return EXIT_FAILURE;}
       
        try{reader_Bone_2->Update();}
       catch (const itk::ExceptionObject & excp)
       {std::cerr << "Exception thrown while writing the image" << std::endl;std::cerr << excp << std::endl;
       return EXIT_FAILURE;}
       
        auto image_for_bone_segmentation = reader_Bone->GetOutput();
          
        auto segmented_bone_image = reader_Bone_2->GetOutput();
        segmented_bone_image->FillBuffer(0.0);

        segmented_bone_image->SetSpacing(spacing);
        segmented_bone_image->SetOrigin(newOrigin);
        segmented_bone_image->SetDirection(direction);   
          
        Segment_Bone(image_for_bone_segmentation, segmented_bone_image, bone_threshold_factor_percentage);
          
        auto CastFilter_Bone = CastFilter_Bone_Type::New();
        CastFilter_Bone->SetInput(segmented_bone_image);

        auto writer_bone = WriterType_Bone::New();
        writer_bone->SetFileName("SEGMENTED BONES.dcm");
        writer_bone->SetInput(CastFilter_Bone->GetOutput());
        writer_bone->Update();

This should be: Segment_Bone<ImageType>(image_for_bone_segmentation, segmented_bone_image, bone_threshold_factor_percentage); The change is Segment_Bone(...) to Segment_Bone<ImageType>(...). Compiler isn’t smart enough to deduce this, so we have to write it explicitly.