예제 #1
0
typename ImageType::Pointer convolveImageHelper(
  typename ImageType::Pointer image,
  typename ImageType::Pointer kernel )
{
  enum { Dimension = ImageType::ImageDimension };
  if( image.IsNotNull() & kernel.IsNotNull() )
    {
    typedef itk::ConvolutionImageFilter<ImageType> FilterType;
    typename FilterType::Pointer convolutionFilter = FilterType::New();
    convolutionFilter->SetInput( image );
    convolutionFilter->SetKernelImage( kernel );
    convolutionFilter->Update();
    return convolutionFilter->GetOutput();
    }
  return NULL;
}
예제 #2
0
medAbstractJob::medJobExitStatus medItkErodeImageProcess::_run()
{
    typedef itk::Image<inputType, 3> ImageType;

    typename ImageType::Pointer in = dynamic_cast<ImageType *>((itk::Object*)(this->input()->data()));

    if(in.IsNotNull())
    {
        typedef itk::BinaryBallStructuringElement<inputType, 3> KernelType;
        typedef itk::GrayscaleErodeImageFilter<ImageType, ImageType, KernelType> FilterType;
        typename FilterType::Pointer filter = FilterType::New();
        m_filter = filter;

        KernelType kernel;
        kernel.SetRadius(this->kernelRadius()->value());
        kernel.CreateStructuringElement();

        filter->SetKernel(kernel);
        filter->SetInput(in);

        itk::CStyleCommand::Pointer callback = itk::CStyleCommand::New();
        callback->SetClientData((void*)this);
        callback->SetCallback(medItkErodeImageProcess::eventCallback);
        filter->AddObserver(itk::ProgressEvent(), callback);

        try
        {
            filter->Update();
        }
        catch(itk::ProcessAborted &e)
        {
            return medAbstractJob::MED_JOB_EXIT_CANCELLED;
        }

        medAbstractImageData *out= dynamic_cast<medAbstractImageData *>(medAbstractDataFactory::instance()->create(this->input()->identifier()));
        out->setData(filter->GetOutput());
        this->setOutput(out);
        return medAbstractJob::MED_JOB_EXIT_SUCCESS;
    }
    return medAbstractJob::MED_JOB_EXIT_FAILURE;
}