[Insight-users] how to write a filter with 2 inputs

Gaetan Lehmann gaetan.lehmann at jouy.inra.fr
Wed Nov 2 05:07:29 EST 2005


On Wed, 02 Nov 2005 00:18:47 +0100, Renaud Isabelle <renauisa at yahoo.fr>  
wrote:

> Hi,
> yes, it is to apply on 2 inputs of the same type: more precisely, on two  
> slices of one image 3D. So, what you mean is that I just have to derive  
> my own filter from itkImageToImageFilter and just modify the constructor  
> of it.

That's it :-)

> Can you give me some filters builded like this?

http://www.itk.org/Doxygen/html/classitk_1_1ReconstructionByDilationImageFilter.html
http://www.itk.org/Doxygen/html/classitk_1_1MaskImageFilter.html
...

> - Moreover, I would like to implement a pixel-wise function as well as  
> functions on the overall of my 2 inputs. But, after a first sight on  
> itkBinaryFunctorImageFilter, it seems that a pixel wise function  
> required to be defined in a ThreadedGenerateData function whereas my  
> operations on the overall input images need GenerateData function, right?

What do you mean by "operations on the overall input images" ?
Do you want to compute an output image ? Or a single value ?
Can you give more precision about what you want to do ?

> ISabelle
>
> Gaetan Lehmann <gaetan.lehmann at jouy.inra.fr> a écrit :
>
> Hi Isabelle,
>
> There is lots of filters with 2 inputs. If you want to have 2 inputs of  
> same
> type, you just have to declare it in the constructor with :
>
> this->SetNumberOfRequiredInputs(2);
>
> If the 2 image can be of different types, it's a little more complex. You
> should look at ConnectedComponentImageFilter which do that. Here is the
> relevant part of code in the header :
>
> void SetMaskImage(TMaskImage* mask) {
> this->SetNthInput(1, const_cast( mask ));
> }
>
> const TMaskImage* GetMaskImage() const {
> return (static_cast(this->ProcessObject::GetInput(1)));
> }
>
> Regards,
>
> Gaetan
>
> On Tuesday 01 November 2005 22:33, Renaud Isabelle wrote:
>> Hi,
>>
>> I am triing to write a filter that will have two inputs and one output.
>>
>> The only example that I found with two inputs is
>> itkBinaryFunctorImageFilter. However, my filter will not compute a
>> pixel-wise operation.
>>
>> I am looking for a file like itkImageToImageFilter but with 2 inputs.  
>> Then,
>> I could derive my own filter from it.
>>
>> Any example or any idea to give, please?
>>
>> Isabelle
>>
>>
>>
>>
>>
>>
>> ---------------------------------
>> Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo!  
>> Messenger
>> Téléchargez le ici !
>
> 		
> ---------------------------------
>  Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo!  
> Messenger
>  Téléchargez le ici !



-- 
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
http://voxel.jouy.inra.fr


More information about the Insight-users mailing list