Skip to content

How to write a new Plugin

luisibanez edited this page Sep 14, 2010 · 7 revisions

Simplest Plug-In

The simplest type of plug-in is the one that takes a single image as input and produce a single image as output and stores that output in the same place as the input image.

The following exercise shows you how to create such plug-in by reusing code from an existing one.

Copy the source from Existing Plug-In

Go to the source tree of the ITK-V3D-Plugins

cd Source
cd IntensityTransformation
cp Sigmoid.h Foo.h
cp Sigmoid.cxx Foo.cxx

  • Edit the Foo.h and Foo.cxx and replace all instances of “Sigmoid” with “Foo”.
  • In Foo.cxx go to line 10 and replace the include of
    • #include “itkFooImageFilter.h”
    • with the actual ITK filter that you want to use
    • Do a similar replacement in line 37:
  • Delete the lines 74-77 that say:
  • this→m_Filter→SetAlpha( 1.0 );
  • this→m_Filter→SetBeta( 128 );
  • this→m_Filter→SetOutputMinimum( 0 );
  • this→m_Filter→SetOutputMaximum( 255 );

Since these parameters (that used to belong to the Sigmoid filter) most likely do not exist in the new filter that you are calling now.

Modify the CMakeLists.txt file

In the same directory edit the file CMakeLists.txt file and add the line

CONFIGURE_V3D_PLUGIN(Foo)

Reconfigure

Go to the binary directory ITK-V3D-Binary-Dir and rerun cmake by doing

make rebuild_cache

then build by typing

make make install

At this point the new plug-In “Foo” will be available in the V3D binary directory.

Run v3d and verify that the “Foo” Plug-In is in the sub-menu of “Intensity Transformations”

Clone this wiki locally