[Paraview] Making vtkImageMathematics available in ParaView filters

Jérôme jerome.velut at gmail.com
Fri Apr 3 11:12:09 EDT 2009


Utkarsh, this is exactly what I want. Thanks a lot !
For those interested in, I give in the following the XML for exposing
vtkImageMathematics filter into ParaView filters menu. They are some weird
behaviour, but I am going further on (like : no "Change input" choice when
right clicking on the Image Math in the pipeline...)

Thanks again !

Jerome

      <!--
================================================================== -->
      <SourceProxy name="ImageMathematics" class="vtkImageMathematics"
label="Image Math">
         <Documentation
                       long_help="Provides some image operations, one or two
inputs."
                       short_help="vtkImageMathematics filter.">
         </Documentation>
         <InputProperty
                       name="Input1"
                       command="SetInputConnection"
                       port_index="0">
            <ProxyGroupDomain name="groups">
               <Group name="sources"/>
               <Group name="filters"/>
            </ProxyGroupDomain>
            <DataTypeDomain name="input_type">
               <DataType value="vtkImageData"/>
            </DataTypeDomain>
            <Documentation>
               Set the input to the Image Mathematics filter.
            </Documentation>
         </InputProperty>
         <InputProperty
                       name="Input2"
                       command="SetInputConnection"
                       port_index="1">
            <ProxyGroupDomain name="groups">
               <Group name="sources"/>
               <Group name="filters"/>
            </ProxyGroupDomain>
            <DataTypeDomain name="input_type">
               <DataType value="vtkImageData"/>
            </DataTypeDomain>
            <Documentation>
               Set the input to the Image Mathematics filter.
            </Documentation>
         </InputProperty>

         <IntVectorProperty
                           name="Operation"
                           command="SetOperation"
                           number_of_elements="1"
                           default_values="0">

            <EnumerationDomain name="enum">
               <Entry value="0" text="Add"/>
               <Entry value="1" text="Substract"/>
               <Entry value="2" text="Multiply"/>
               <Entry value="3" text="Divide"/>
               <Entry value="4" text="Invert"/>
               <Entry value="5" text="Sin"/>
               <Entry value="6" text="Cos"/>
               <Entry value="7" text="Exp"/>
               <Entry value="8" text="Log"/>
               <Entry value="9" text="Abs"/>
               <Entry value="10" text="Sqr"/>
               <Entry value="11" text="Sqrt"/>
               <Entry value="12" text="Min"/>
               <Entry value="13" text="Max"/>
               <Entry value="14" text="Atan"/>
               <Entry value="15" text="Atan2"/>
               <Entry value="16" text="Multiply by k"/>
               <Entry value="17" text="Add c"/>
               <Entry value="18" text="Conjugate"/>
               <Entry value="19" text="Complex multiply"/>
               <Entry value="20" text="Replace by k"/>
            </EnumerationDomain>
         </IntVectorProperty>

         <DoubleVectorProperty
                              name="ConstantK"
                              command="SetConstantK"
                              number_of_elements="1"
                              default_values="1">
         </DoubleVectorProperty>

         <DoubleVectorProperty
                              name="ConstantC"
                              command="SetConstantC"
                              number_of_elements="1"
                              default_values="0">
         </DoubleVectorProperty>

         <IntVectorProperty
                           name="DivideByZeroToC"
                           command="SetDivideByZeroToC"
                           number_of_elements="1"
                           default_values="1">
            <BooleanDomain name="boolean"/>
         </IntVectorProperty>

      </SourceProxy>
      <!-- End ImageMathematics -->

2009/4/3 Utkarsh Ayachit <utkarsh.ayachit at kitware.com>

> You are on the right track. The difference between vtkImageAppend and
> vtkImageMathematics is that the former supports "multiple input
> connections on a single input port" while the latter supports "one
> input connection each on two input ports". This former is supported in
> the XML by using the multiple_input attribute, while for the latter,
> you need to have two separate input properties as follows:
>
> <InputProperty name="Input1" command="SetInputConnection" ... />  <!--
> port_index="0" is by default -->
> <InputProperty name="Input2" port_index="1" command="SetInputConnection"
> ... />
>
> The key here is the "port_index" attribute.
>
> Utkarsh
>
> On Fri, Apr 3, 2009 at 2:53 AM, Jérôme <jerome.velut at gmail.com> wrote:
> > Ok !
> > No, it doesn't work, but I made my mind:
> >
> > * vtkImageMathematics has two input ports, the second one being optional.
> > That's why the XML works with one filter.
> >
> > * Function SetInput1 and SetInput2 are wrappers around SetInputConnection
> > for old-style programming compatibility. SetInputX is in fact
> > SetInputConnection(X-1, input_port1 )
> >
> > When using AddInputConnection like vtkImageAppend does, it is based on
> the
> > 'one port' fashion of the filter, then multiple inputs means multiple
> > connections on one port... That is not the case for vtkImageMathematics
> !!
> >
> > So, I would like to use kind of number_of_elements statement and
> > element_types statement to handle something like :
> > <InputProperty
> >                        name="Input1"
> >                        command="SetInputConnection"
> >                        number_of_elements="2"
> >                        element_types="0 3"   <!-- Yes I know, type '3'
> does
> > not exist: I want this to be vtkAlgorithmOutput -->
> >                        default_values="0 Input1"> <!-- Yes I know, but
> you
> > see what I means ?? -->
> >             <ProxyGroupDomain name="groups">
> >                   <Group name="sources"/>
> >                   <Group name="filters"/>
> >             </ProxyGroupDomain>
> >             <DataTypeDomain name="input_type">
> >                  <DataType value="vtkImageData"/>
> >             </DataTypeDomain>
> >             <Documentation>
> >                   Set the input to the vtkImageMathematics filter.
> >             </Documentation>
> >   </InputProperty>
> >
> > And then the same with Input2, where default_values would be "1 Input2".
> > I know one solution is to create an inherited class from
> > vtkImageMathematics, with accessors on input port 0 and port 1. I already
> > did that for vtkImageStencil, what works fine. My problem here is to make
> > vtkImageMathematic available without building any plugins: c++-allergics
> > have rights to use image addition and substraction inside ParaView !! one
> > XML to load, that's all !
> >
> > I hope -for these allergics- that there is a solution...
> >
> > Best regards
> >
> > Jerome
> >
> > 2009/4/2 Jérôme <jerome.velut at gmail.com>
> >>
> >> Hi,
> >>
> >> Many thanks for your quick answer. The problem I described was observed
> on
> >> Paraview 3.4 release, debug build. I have a 3.5 CVS (not updated, so
> bad...)
> >> on which I tried my XML just right now: "Image Math" is no more gray!! I
> am
> >> able to apply the filter on a single image, with "Add constant",
> "Multiply
> >> by constant", etc.
> >>
> >> The new problem is when I want to add two image. I selected two
> mandelbrot
> >> sources, then I plugged the "Image Math" filter. The output window
> claims:
> >> "Input port 0 of algorithm vtkImageMathematics(0x7f081c4bcb70) has 2
> >> connections but is not repeatable".
> >>
> >> I tried the repeat_command="1" statement, without optimism and not much
> >> success... It seems that vtkImageMathematics input is old-fashionned,
> but
> >> the VTK doc says that SetInput1 and SetInput2 is like involking
> >> AddInputConnection. Where do I miss something ???
> >>
> >> Thanks for all,
> >>
> >> Jerome
> >>
> >> 2009/4/2 Utkarsh Ayachit <utkarsh.ayachit at kitware.com>
> >>>
> >>> I justed loaded your XML as a plugin in CVS ParaView is seems to being
> >>> enabled fine. I was able to apply the filter to Mandlebrot source.
> >>> What version of ParaView are you using?
> >>>
> >>> Utkarsh
> >>>
> >>> 2009/4/2 Jérôme <jerome.velut at gmail.com>:
> >>> > Dear all,
> >>> >
> >>> > I am unsuccessfully fighting with XML description of the VTK
> >>> > vtkImageMathematics filter. I want it to be available in the ParaView
> >>> > filters. At the end of this mail is the XML I wrote, widely inspired
> >>> > from
> >>> > "Append Geometry".
> >>> >
> >>> > Note that it is part of a larger file making available
> >>> > ImageGaussianSmooth,
> >>> > ImageSobel3D, ImageFilp, SplineFilter, some different sources...
> >>> > Everything
> >>> > works well, except Image Mathematics and Image Reslice (I told about
> >>> > Reslice
> >>> > in another thread).
> >>> >
> >>> > The symptom is the following : the "Image Math" appears in the
> filters
> >>> > list,
> >>> > but is always unavailable, even if I select one proxy or two in the
> >>> > pipeline. What is the diagnostic, doctors ? Is there a therapy ?
> >>> >
> >>> > Thanks all !
> >>> >
> >>> > Best regards,
> >>> > Jerome
> >>> >
> >>> > <ServerManagerConfiguration>
> >>> >    <ProxyGroup name="filters">
> >>> >       <!--
> >>> > ==================================================================
> -->
> >>> >       <SourceProxy name="ImageMathematics"
> class="vtkImageMathematics"
> >>> > label="Image Math">
> >>> >          <Documentation
> >>> >                        long_help="Provides some image operations, one
> >>> > or two
> >>> > inputs."
> >>> >                        short_help="vtkImageMathematics filter.">
> >>> >          </Documentation>
> >>> >       <InputProperty
> >>> >          name="Input"
> >>> >          command="AddInputConnection"
> >>> >          clean_command="RemoveAllInputs"
> >>> >          multiple_input="1">
> >>> >            <ProxyGroupDomain name="groups">
> >>> >              <Group name="sources"/>
> >>> >              <Group name="filters"/>
> >>> >            </ProxyGroupDomain>
> >>> >            <DataTypeDomain name="input_type">
> >>> >              <DataType value="vtkImageData"/>
> >>> >            </DataTypeDomain>
> >>> >            <Documentation>
> >>> >              Set the input to the Append Geometry filter.
> >>> >            </Documentation>
> >>> >       </InputProperty>
> >>> >
> >>> >          <IntVectorProperty
> >>> >                            name="Operation"
> >>> >                            command="SetOperation"
> >>> >                            number_of_elements="1"
> >>> >                            default_values="0">
> >>> >
> >>> >             <EnumerationDomain name="enum">
> >>> >                <Entry value="0" text="Add"/>
> >>> >                <Entry value="1" text="Substract"/>
> >>> >                <Entry value="2" text="Multiply"/>
> >>> >                <Entry value="3" text="Divide"/>
> >>> >                <Entry value="4" text="Invert"/>
> >>> >                <Entry value="5" text="Sin"/>
> >>> >                <Entry value="6" text="Cos"/>
> >>> >                <Entry value="7" text="Exp"/>
> >>> >                <Entry value="8" text="Log"/>
> >>> >                <Entry value="9" text="Abs"/>
> >>> >                <Entry value="10" text="Sqr"/>
> >>> >                <Entry value="11" text="Sqrt"/>
> >>> >                <Entry value="12" text="Min"/>
> >>> >                <Entry value="13" text="Max"/>
> >>> >                <Entry value="14" text="Atan"/>
> >>> >                <Entry value="15" text="Atan2"/>
> >>> >                <Entry value="16" text="Multiply by k"/>
> >>> >                <Entry value="17" text="Add c"/>
> >>> >                <Entry value="18" text="Conjugate"/>
> >>> >                <Entry value="19" text="Complex multiply"/>
> >>> >                <Entry value="20" text="Replace by k"/>
> >>> >             </EnumerationDomain>
> >>> >          </IntVectorProperty>
> >>> >
> >>> >          <DoubleVectorProperty
> >>> >                               name="ConstantK"
> >>> >                               command="SetConstantK"
> >>> >                               number_of_elements="1"
> >>> >                               default_values="1">
> >>> >          </DoubleVectorProperty>
> >>> >
> >>> >          <DoubleVectorProperty
> >>> >                               name="ConstantC"
> >>> >                               command="SetConstantC"
> >>> >                               number_of_elements="1"
> >>> >                               default_values="0">
> >>> >          </DoubleVectorProperty>
> >>> >
> >>> >          <IntVectorProperty
> >>> >                            name="DivideByZeroToC"
> >>> >                            command="SetDivideByZeroToC"
> >>> >                            number_of_elements="1"
> >>> >                            default_values="1">
> >>> >             <BooleanDomain name="boolean"/>
> >>> >          </IntVectorProperty>
> >>> >
> >>> >       </SourceProxy>
> >>> >       <!-- End ImageMathematics -->
> >>> >    </ProxyGroup>
> >>> >    <!-- End Filters Group -->
> >>> > </ServerManagerConfiguration>
> >>> >
> >>> >
> >>> >
> >>> > _______________________________________________
> >>> > Powered by www.kitware.com
> >>> >
> >>> > Visit other Kitware open-source projects at
> >>> > http://www.kitware.com/opensource/opensource.html
> >>> >
> >>> > Please keep messages on-topic and check the ParaView Wiki at:
> >>> > http://paraview.org/Wiki/ParaView
> >>> >
> >>> > Follow this link to subscribe/unsubscribe:
> >>> > http://www.paraview.org/mailman/listinfo/paraview
> >>> >
> >>> >
> >>
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20090403/e12ec26e/attachment-0001.htm>


More information about the ParaView mailing list