1 /*=========================================================================
3 Module: $RCSfile: bbitkExtractImageFilter.h,v $
5 Date: $Date: 2008/10/17 08:18:21 $
6 Version: $Revision: 1.8 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
34 #include "bbtkAtomicBlackBox.h"
35 #include "itkExtractImageFilter.h"
36 #include "bbtkItkBlackBoxMacros.h"
37 #include "bbitkImage.h"
38 #include "bbitkImageRegion.h"
45 class /*BBTK_EXPORT*/ ExtractImageFilter
47 public bbtk::AtomicBlackBox,
48 public itk::ExtractImageFilter<T,T>
50 BBTK_TEMPLATE_BLACK_BOX_INTERFACE(ExtractImageFilter,
53 typedef itk::ExtractImageFilter<T,T> itkParent;
55 BBTK_DECLARE_ITK_INPUT(In,const T*);
56 BBTK_DECLARE_ITK_PARAM(ExtractionRegion,typename T::RegionType);
57 BBTK_DECLARE_ITK_OUTPUT(Out,T*);
64 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(ExtractImageFilter,
65 bbtk::AtomicBlackBox);
66 BBTK_NAME("ExtractImageFilter<"+bbtk::TypeName<T>()+">");
67 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
68 BBTK_DESCRIPTION("Decrease the image size by cropping the image to the selected region bounds (bbification of itk::ExtractImageFilter)");
69 BBTK_TEMPLATE_INPUT(ExtractImageFilter,In,"Input image",const T*);
70 BBTK_TEMPLATE_INPUT(ExtractImageFilter,ExtractionRegion,"Extraction region",typename T::RegionType);
71 BBTK_TEMPLATE_OUTPUT(ExtractImageFilter,Out,"Output image",T*);
72 BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(ExtractImageFilter);
74 //===================================================
75 // Generic "untemplatized" filter
76 //===================================================
77 class /*BBTK_EXPORT*/ ExtractImageFilterGeneric
78 : public bbtk::AtomicBlackBox
80 BBTK_BLACK_BOX_INTERFACE(ExtractImageFilterGeneric,
81 bbtk::AtomicBlackBox);
82 BBTK_DECLARE_INPUT(In,anyImagePointer);
83 BBTK_DECLARE_INPUT(Region,anyImageRegion);
84 BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
85 BBTK_PROCESS(ProcessSwitch);
87 inline void ProcessSwitch();
88 template <class T> void Process();
91 BBTK_BEGIN_DESCRIBE_BLACK_BOX(ExtractImageFilterGeneric,
92 bbtk::AtomicBlackBox);
93 BBTK_NAME("ExtractImageFilter");
94 BBTK_AUTHOR("laurent.guigues at creatis.insa-lyon.fr");
95 BBTK_CATEGORY("image;filter");
96 BBTK_DESCRIPTION("Decrease the image size by cropping the image to the selected region bounds (bbification of itk::ExtractImageFilter)");
97 BBTK_INPUT(ExtractImageFilterGeneric,In,"Input image",anyImagePointer,"");
98 BBTK_INPUT(ExtractImageFilterGeneric,Region,"Extraction region",anyImageRegion,"");
99 BBTK_OUTPUT(ExtractImageFilterGeneric,Out,"Output image",anyImagePointer,"");
100 BBTK_END_DESCRIBE_BLACK_BOX(ExtractImageFilterGeneric);
101 void ExtractImageFilterGeneric::ProcessSwitch()
103 BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(), this->Process);
107 void ExtractImageFilterGeneric::Process()
109 bbtkDebugMessageInc("Core",9,
110 "bbitk::ExtractImageFilterGeneric::Process<"
111 <<bbtk::TypeName<T>()<<">()"<<std::endl);
113 typedef ExtractImageFilter<ImageType> FilterType;
114 typename FilterType::Pointer f = FilterType::New("Temp");
115 f->bbSetInputIn( this->bbGetInputIn().unsafe_get<T*>() );
116 f->bbSetInputExtractionRegion ( this->bbGetInputRegion().get<typename T::RegionType>() );
118 f->bbGetOutputOut()->Register();
119 this->bbSetOutputOut( f->bbGetOutputOut() );
122 bbtkDebugDecTab("Core",9);
126 // EO namespace bbitk