ITK/Tutorials/DOs and DONTs: Difference between revisions

From KitwarePublic
< ITK‎ | Tutorials
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
= PipeLine =
= PipeLine =


Line 6: Line 5:
* Do call Update() before using the pipeline output
* Do call Update() before using the pipeline output


= Filter-Specific =
== itkConnectedComponentsImageFilter==
=== DO NOT ===
* Do not assume InputImage->SetRequestedRegion(smallregion) will make the filter faster! The filter will run on the entire InputImage regardless.
=== DO ===
* To make it run on a smaller block:
**get a new itkRegionOfInterestImageFilter, say ROIfilter
** ROIfilter->SetInput(InputImage);
** ROIfilter->SetRegionOfInterest(smallregion);
** CCfilter->SetInput (ROIfilter->GetOutput());


= Image Creation =
= Image Creation =
Line 19: Line 28:
== DO NOT ==
== DO NOT ==


* Do not declare constanst using  
* Do not declare constants using  
** #define CONST_VALUE_NAME 3
** #define CONST_VALUE_NAME 3
** Use instead
** Use instead
*** const unsigned int CONST_VALUE_NAME = 3,   
*** const unsigned int CONST_VALUE_NAME = 3,   
* ITK doesn't define constants with  #defines in header files
* ITK doesn't define constants with  #defines in header files

Revision as of 15:27, 7 July 2009

PipeLine

DO

  • Do call Update() before using the pipeline output

Filter-Specific

itkConnectedComponentsImageFilter

DO NOT

  • Do not assume InputImage->SetRequestedRegion(smallregion) will make the filter faster! The filter will run on the entire InputImage regardless.

DO

  • To make it run on a smaller block:
    • get a new itkRegionOfInterestImageFilter, say ROIfilter
    • ROIfilter->SetInput(InputImage);
    • ROIfilter->SetRegionOfInterest(smallregion);
    • CCfilter->SetInput (ROIfilter->GetOutput());

Image Creation

DO

  • On a newly-manually-created image, do initialize the pixel values if you expect them to be so!
    • Example: image->FillBuffer(0); // initialize it to all dark
    • ITK doesn't initialize the image buffer when you call Allocate(). It is your responsibility to initialize the pixel values.

Coding Style

DO NOT

  • Do not declare constants using
    • #define CONST_VALUE_NAME 3
    • Use instead
      • const unsigned int CONST_VALUE_NAME = 3,
  • ITK doesn't define constants with #defines in header files