# How to use MakeOutput() in class which derives from ProcessObject

**URL:** https://discourse.itk.org/t/how-to-use-makeoutput-in-class-which-derives-from-processobject/3785
**Category:** Uncategorized
**Created:** [January 21, 2021, 10:33am UTC](https://discourse.itk.org/t/how-to-use-makeoutput-in-class-which-derives-from-processobject/3785 "2021-01-21T10:33:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Stefan\_Radonjic](https://discourse.itk.org/user_avatar/discourse.itk.org/stefan_radonjic/32/1793_2.png) [@Stefan\_Radonjic](https://discourse.itk.org/u/Stefan_Radonjic)
#### Post date: [January 21, 2021, 10:33am UTC](https://discourse.itk.org/t/how-to-use-makeoutput-in-class-which-derives-from-processobject/3785/1 "2021-01-21T10:33:40Z")

</div>

I had a class which was deriving from `ImageToImage` filter and in its constructor I was setting Inputs and Outputs in the following manner:

```
this->SetPrimaryInputName("BaselineImage");
this->AddRequiredInputName("BaselineImage");
this->AddRequiredInputName("FollowupImage");
this->AddRequiredInputName("BaselineICC");
this->AddRequiredInputName("FollowupICC");
this->SetNumberOfRequiredOutputs( 2 );
this->SetOutput("BaselineImage",this->MakeOutput(0)); 
this->SetOutput("FollowupImage",this->MakeOutput(1));
this->SetTransformationTypeToCombined(); 

```

Here is how the class has been derived:

```
template<typename BaselineImageType, typename FollowupImageType, typename MaskType>
	class MyFilterClass : public itk::ImageToImageFilter<BaselineImageType, itk::Image<float,BaselineImageType::ImageDimension> >

```

This worked, but I am now trying to derive from `ProcessObject` instead:

```
template<typename BaselineImageType, typename FollowupImageType, typename MaskType>
	class MyFilterClass : public itk::ProcessObject

```

And for some reason I am receiving now: `Segmentation Fault (core dumped)`. I’ve tried debugging it and I figured it is occurring during the call of `MakeOutput(0).`

Any ideas why this is happening and how can avoid using `MakeOutput` when deriving from `ProcessObject`, or at least use it correctly?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [January 21, 2021, 2:35pm UTC](https://discourse.itk.org/t/how-to-use-makeoutput-in-class-which-derives-from-processobject/3785/2 "2021-01-21T14:35:21Z")

</div>

If you decided to derive from `ProcessObject`, you will need to override more methods than when inheriting from `ImageToImageFilter`. You probably need to override `MakeOutput()`. You could look for inspiration in `ImageToImageFilter`'s version of it, or maybe in `ImageSource`'s version (one of them might not exist).

If you are running it in debug mode with full debug symbols, your IDE should tell you where the exception is occurring, not just silently crash. Knowing where the crash is happening should allow you to focus your attention more effectively.

---

<div class="post-metadata">

### Author: ![Stefan\_Radonjic](https://discourse.itk.org/user_avatar/discourse.itk.org/stefan_radonjic/32/1793_2.png) [@Stefan\_Radonjic](https://discourse.itk.org/u/Stefan_Radonjic)
#### Post date: [February 19, 2021, 10:13am UTC](https://discourse.itk.org/t/how-to-use-makeoutput-in-class-which-derives-from-processobject/3785/3 "2021-02-19T10:13:14Z")

</div>

Sorry for late response. It did work like a charm 🙂
