test.cxx | test.cxx | |||
---|---|---|---|---|
skipping to change at line 51 | skipping to change at line 51 | |||
#include "vigra/labelvolume.hxx" | #include "vigra/labelvolume.hxx" | |||
using namespace vigra; | using namespace vigra; | |||
struct VolumeLabelingTest | struct VolumeLabelingTest | |||
{ | { | |||
typedef vigra::MultiArray<3,int> IntVolume; | typedef vigra::MultiArray<3,int> IntVolume; | |||
typedef vigra::MultiArray<3,double> DoubleVolume; | typedef vigra::MultiArray<3,double> DoubleVolume; | |||
VolumeLabelingTest() | VolumeLabelingTest() | |||
: vol1(IntVolume::difference_type(4,4,4)),vol2(IntVolume::difference_ty | : vol1(IntVolume::difference_type(4,4,4)),vol2(IntVolume::difference_ty | |||
pe(4,4,4)),vol3(IntVolume::difference_type(5,5,5)),vol4(DoubleVolume::diffe | pe(4,4,4)), | |||
rence_type(5,5,5)),vol5(DoubleVolume::difference_type(5,5,5)) | vol3(IntVolume::difference_type(5,5,5)),vol4(DoubleVolume::difference | |||
_type(5,5,5)), | ||||
vol5(DoubleVolume::difference_type(5,5,5)),vol6(DoubleVolume::differe | ||||
nce_type(5,5,5)) | ||||
{ | { | |||
static const int in1[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, | static const int in1[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, | |||
0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0 , 0, 0, 0, 0, | 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0 , 0, 0, 0, 0, | |||
0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0 , 0, 0, 0, 0, | 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0 , 0, 0, 0, 0, | |||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0}; | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0}; | |||
IntVolume::iterator i = vol1.begin(); | IntVolume::iterator i = vol1.begin(); | |||
IntVolume::iterator end = vol1.end(); | IntVolume::iterator end = vol1.end(); | |||
const int * p = in1; | const int * p = in1; | |||
skipping to change at line 126 | skipping to change at line 128 | |||
id = vol5.begin(); | id = vol5.begin(); | |||
endd = vol5.end(); | endd = vol5.end(); | |||
pd = in5; | pd = in5; | |||
for(; id != endd; ++id, ++pd) | for(; id != endd; ++id, ++pd) | |||
{ | { | |||
*id=*pd; | *id=*pd; | |||
} | } | |||
static const double in6[] = { | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
1.0, 1.0, 0.0, 1.0, 1.0, | ||||
1.0, 1.0, 0.0, 1.0, 1.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
1.0, 1.0, 0.0, 1.0, 1.0, | ||||
1.0, 1.0, 0.0, 1.0, 1.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0, | ||||
0.0, 0.0, 0.0, 0.0, 0.0 }; | ||||
id = vol6.begin(); | ||||
endd = vol6.end(); | ||||
pd = in6; | ||||
for(; id != endd; ++id, ++pd) | ||||
{ | ||||
*id=*pd; | ||||
} | ||||
} | } | |||
void labelingSixTest1() | void labelingSixTest1() | |||
{ | { | |||
IntVolume res(vol1); | IntVolume res(vol1); | |||
unsigned int maxLabel = labelVolumeSix(srcMultiArrayRange(vol1), de stMultiArray(res)); | unsigned int maxLabel = labelVolumeSix(srcMultiArrayRange(vol1), de stMultiArray(res)); | |||
should(2 == maxLabel); | should(2 == maxLabel); | |||
IntVolume::iterator i1 = vol1.begin(); | IntVolume::iterator i1 = vol1.begin(); | |||
skipping to change at line 292 | skipping to change at line 334 | |||
DoubleVolume::iterator i1 = vol5.begin(); | DoubleVolume::iterator i1 = vol5.begin(); | |||
DoubleVolume::iterator i1end = vol5.end(); | DoubleVolume::iterator i1end = vol5.end(); | |||
IntVolume::iterator i2 = res.begin(); | IntVolume::iterator i2 = res.begin(); | |||
for(; i1 != i1end; ++i1, ++i2) | for(; i1 != i1end; ++i1, ++i2) | |||
{ | { | |||
should( *i1 == *i2 ); | should( *i1 == *i2 ); | |||
} | } | |||
} | } | |||
void labelingAllTest() | ||||
{ | ||||
IntVolume res(vol6.shape()); | ||||
static const int out6[] = { | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
1, 1, 0, 2, 2, | ||||
1, 1, 0, 2, 2, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
1, 1, 0, 2, 2, | ||||
1, 1, 0, 2, 2, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0 }; | ||||
should(2 == labelVolumeWithBackground(srcMultiArrayRange(vol6), des | ||||
tMultiArray(res), NeighborCode3DSix(), 0)); | ||||
shouldEqualSequence(res.begin(), res.end(), out6); | ||||
should(2 == labelVolumeWithBackground(srcMultiArrayRange(vol6), des | ||||
tMultiArray(res), NeighborCode3DTwentySix(), 0)); | ||||
shouldEqualSequence(res.begin(), res.end(), out6); | ||||
should(3 == labelVolume(srcMultiArrayRange(vol6), destMultiArray(re | ||||
s), NeighborCode3DSix())); | ||||
res -= 1; | ||||
shouldEqualSequence(res.begin(), res.end(), out6); | ||||
should(3 == labelVolume(srcMultiArrayRange(vol6), destMultiArray(re | ||||
s), NeighborCode3DTwentySix())); | ||||
res -= 1; | ||||
shouldEqualSequence(res.begin(), res.end(), out6); | ||||
} | ||||
IntVolume vol1, vol2, vol3; | IntVolume vol1, vol2, vol3; | |||
DoubleVolume vol4, vol5; | DoubleVolume vol4, vol5, vol6; | |||
}; | }; | |||
struct VolumeLabelingTestSuite | struct VolumeLabelingTestSuite | |||
: public vigra::test_suite | : public vigra::test_suite | |||
{ | { | |||
VolumeLabelingTestSuite() | VolumeLabelingTestSuite() | |||
: vigra::test_suite("VolumeLabelingTestSuite") | : vigra::test_suite("VolumeLabelingTestSuite") | |||
{ | { | |||
add( testCase( &VolumeLabelingTest::labelingSixTest1)); | add( testCase( &VolumeLabelingTest::labelingSixTest1)); | |||
add( testCase( &VolumeLabelingTest::labelingSixTest2)); | add( testCase( &VolumeLabelingTest::labelingSixTest2)); | |||
add( testCase( &VolumeLabelingTest::labelingSixTest3)); | add( testCase( &VolumeLabelingTest::labelingSixTest3)); | |||
add( testCase( &VolumeLabelingTest::labelingSixTest4)); | add( testCase( &VolumeLabelingTest::labelingSixTest4)); | |||
add( testCase( &VolumeLabelingTest::labelingSixWithBackgroundTest1) ); | add( testCase( &VolumeLabelingTest::labelingSixWithBackgroundTest1) ); | |||
add( testCase( &VolumeLabelingTest::labelingTwentySixTest1)); | add( testCase( &VolumeLabelingTest::labelingTwentySixTest1)); | |||
add( testCase( &VolumeLabelingTest::labelingTwentySixTest2)); | add( testCase( &VolumeLabelingTest::labelingTwentySixTest2)); | |||
add( testCase( &VolumeLabelingTest::labelingTwentySixTest3)); | add( testCase( &VolumeLabelingTest::labelingTwentySixTest3)); | |||
add( testCase( &VolumeLabelingTest::labelingTwentySixWithBackground Test1)); | add( testCase( &VolumeLabelingTest::labelingTwentySixWithBackground Test1)); | |||
add( testCase( &VolumeLabelingTest::labelingAllTest)); | ||||
} | } | |||
}; | }; | |||
int main(int argc, char ** argv) | int main(int argc, char ** argv) | |||
{ | { | |||
VolumeLabelingTestSuite test; | VolumeLabelingTestSuite test; | |||
int failed = test.run(vigra::testsToBeExecuted(argc, argv)); | int failed = test.run(vigra::testsToBeExecuted(argc, argv)); | |||
std::cout << test.report() << std::endl; | std::cout << test.report() << std::endl; | |||
End of changes. 5 change blocks. | ||||
4 lines changed or deleted | 102 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |