22 #ifndef __TestFilterBase_hh__
23 #define __TestFilterBase_hh__
25 #include <Base/Debug/Error.hh>
26 #include <Base/Image/Image.hh>
27 #include <Filter/FilterBase.hh>
28 #include <Filter/FilterMask.hh>
42 template <
typename InputStorageType,
typename OutputStorageType>
48 : Input(input), Output(output),
50 OutputStorageType>::TBH_valid), Mask() {}
70 template <
template <
typename,
typename>
class FILTER,
71 typename InputStorageType,
typename OutputStorageType>
82 OutputStorageType> &data);
86 FILTER<InputStorageType, OutputStorageType>
Filter_;
88 std::vector<FilterTestPair<InputStorageType, OutputStorageType> >
Data_;
94 bool TestBorderHandling_();
114 template <
template <
typename,
typename>
class FILTER,
115 typename InputStorageType,
typename OutputStorageType>
119 if (!TestBorderHandling_()) {
return false; }
121 if (!TestData_()) {
return false; }
128 template <
template <
typename,
typename>
class FILTER,
129 typename InputStorageType,
typename OutputStorageType>
134 Data_.push_back(data);
139 template <
template <
typename,
typename>
class FILTER,
140 typename InputStorageType,
typename OutputStorageType>
144 const int sze = 100, roioffs = 2;
145 BIASASSERT(2*roioffs<sze);
150 const unsigned src_roi[]={roioffs, roioffs, sze-roioffs, sze-roioffs};
151 src.
SetROICorners(src_roi[0], src_roi[1], src_roi[2], src_roi[3]);
157 if (Filter_.Filter(src, dst)!=0){ BIASABORT; }
158 if (!CompareHeader_(src, dst)) { BIASABORT; }
159 dst.
GetROICorners(dst_roi[0], dst_roi[1], dst_roi[2], dst_roi[3]);
161 Filter_.GetBorders(roi_offs[0], roi_offs[1]);
162 roi_offs[2] = -roi_offs[0]; roi_offs[3] = -roi_offs[1];
163 for (
int i=0; i<4; i++){
166 if ((
int)src_roi[i] + roi_offs[i] != (
int)dst_roi[i]){ BIASABORT; }
172 if (Filter_.Filter(src, dst)!=0){ BIASABORT; }
173 if (!CompareHeader_(src, dst)) { BIASABORT; }
174 dst.
GetROICorners(dst_roi[0], dst_roi[1], dst_roi[2], dst_roi[3]);
175 for (
int i=0; i<4; i++){
176 if (src_roi[i] != dst_roi[i]){ BIASABORT; }
190 template <
template <
typename,
typename>
class FILTER,
191 typename InputStorageType,
typename OutputStorageType>
195 for (
unsigned i=0; i<Data_.size(); i++){
197 Filter_.SetBorderHandling(Data_[i].BorderHandling);
198 if (Filter_.Filter(Data_[i].Input, dst)!=0){ BIASABORT; }
199 if (!CompareHeader_(Data_[i].Output, dst)) { BIASABORT; }
200 if (!CompareImageData_(Data_[i].Output, dst)) { BIASABORT; }
206 template <
template <
typename,
typename>
class FILTER,
207 typename InputStorageType,
typename OutputStorageType>
220 template <
template <
typename,
typename>
class FILTER,
221 typename InputStorageType,
typename OutputStorageType>
227 unsigned gt_roi[4], dst_roi[4];
228 gt.
GetROICorners(gt_roi[0], gt_roi[1], gt_roi[2], gt_roi[3]);
229 dst.
GetROICorners(dst_roi[0], dst_roi[1], dst_roi[2], dst_roi[3]);
236 register unsigned x, y, c;
237 for (y=dst_roi[1]; y<dst_roi[3]; y++){
238 for (x=dst_roi[1]; x<dst_roi[3]; x++){
239 for (c=0; c<cc; c++){
240 if (!
Equal(dst_ida[y][x*cc+c], gt_ida[y][x*cc+c])) {
241 cout <<
"y: "<<y<<
"\tx: "<<x<<
"\tcc: "<<cc<<
"\tcc: "<<c<<endl
242 <<
"dst_ida[y][x*cc+c]: "<<(int)dst_ida[y][x*cc+c]
243 <<
"\tgt_ida[y][x*cc+c]: "<<(
int)gt_ida[y][x*cc+c]<<endl;
256 #endif // __TestFilterBase_hh__
struct holding ground truth data for filter testing\
FILTER< InputStorageType, OutputStorageType > Filter_
Image< InputStorageType > Input
input image
bool IsInterleaved() const
virtual parent class for API definition of all (future) filters
unsigned int GetWidth() const
TBorderHandling
enum for border calculation, same meanings as in matlab:
void GetROICorners(unsigned int &UpperLeftX, unsigned int &UpperLeftY, unsigned int &LowerRightX, unsigned int &LowerRightY) const
access region of interest rectangle JW
std::vector< FilterTestPair< InputStorageType, OutputStorageType > > Data_
FilterTestPair(const Image< InputStorageType > input, const Image< OutputStorageType > output)
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
unsigned int GetHeight() const
void FillImageWithConstValue(StorageType Value)
fill grey images
bool SamePixelAndChannelCount(const ImageBase &Image) const
checks if data area has same "size" as Image of other type
bool Equal(const T left, const T right, const T eps)
comparison function for floating point values See http://www.boost.org/libs/test/doc/components/test_...
enum EColorModel GetColorModel() const
Image< OutputStorageType > Output
helper class for testing individual filters
int SetROICorners(unsigned int UpperLeftX, unsigned int UpperLeftY, unsigned int LowerRightX, unsigned int LowerRightY)
A filter mask (or a kernel) used for convolution.
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase