From 7cfcbedcabc87bce6dd6009e53b6ba05f9d406a9 Mon Sep 17 00:00:00 2001 From: Arun Kumar Date: Fri, 6 Nov 2015 15:56:00 +0000 Subject: [PATCH 1/4] Fixed hill orientation and tests --- Sources/Extraction/Filters/HillOrientation.c | 22 ++++++++++--------- .../Extraction/Filters/Test_HillOrientation.c | 8 +++++++ .../runners/TestRunner_HillOrientation.c | 4 ++-- Sources/Tests/all_tests.c | 4 ++-- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Sources/Extraction/Filters/HillOrientation.c b/Sources/Extraction/Filters/HillOrientation.c index 5438642..16b511c 100644 --- a/Sources/Extraction/Filters/HillOrientation.c +++ b/Sources/Extraction/Filters/HillOrientation.c @@ -78,25 +78,27 @@ static PointFArray2D HillOrientation_AccumulateDirections(FloatArray2D input, in static PointFArray2D HillOrientation_SumBlocks(const PointFArray2D * pixelOrientations, const BinaryMap * blockMask, const BlockMap * blocks) { const PointFArray2D blockOrientations = PointFArray2D_Construct(blocks->blockCount.width, blocks->blockCount.height); - const int blockHeight = blocks->maxBlockSize; - const int blockWidth = blocks->maxBlockSize; - for (int blockX = 0; blockX < blocks->blockCount.width; blockX++) + Point block; + for (block.y = RectangleC_GetBottom(&blocks->allBlocks); block.y < RectangleC_GetTop(&blocks->allBlocks); block.y++) { - for (int blockY = 0; blockY < blocks->blockCount.height; blockY++) + for (block.x = RectangleC_GetLeft(&blocks->allBlocks); block.x < RectangleC_GetRight(&blocks->allBlocks); block.x++) { - if (!BinaryMap_GetBit(blockMask, blockX, blockY)) + if (!BinaryMap_GetBit(blockMask, block.x, block.y)) continue; - int bottomLeftX = blocks->blockAreas.corners.allX.data[blockX]; - int bottomLeftY = blocks->blockAreas.corners.allY.data[blockY]; - for (int x = bottomLeftX; x < bottomLeftX + blockWidth; ++x) { - for ( int y = bottomLeftY; y < bottomLeftY + blockHeight; ++y ) { - blockOrientations.data[blockX][blockY] = Calc_Add2PointsF(&blockOrientations.data[blockX][blockY], &pixelOrientations->data[x][y]); + RectangleC blockArea = RectangleGrid_GetRectangleCFromPoint(&blocks->blockAreas, &block); + + for (int x = RectangleC_GetLeft(&blockArea); x < RectangleC_GetRight(&blockArea); x++) + { + for (int y = RectangleC_GetBottom(&blockArea); y < RectangleC_GetTop(&blockArea); y++) + { + blockOrientations.data[block.x][block.y] = Calc_Add2PointsF(&blockOrientations.data[block.x][block.y], &pixelOrientations->data[x][y]); } } } } + return blockOrientations; } diff --git a/Sources/Tests/Extraction/Filters/Test_HillOrientation.c b/Sources/Tests/Extraction/Filters/Test_HillOrientation.c index 64169ed..26b3550 100755 --- a/Sources/Tests/Extraction/Filters/Test_HillOrientation.c +++ b/Sources/Tests/Extraction/Filters/Test_HillOrientation.c @@ -51,6 +51,12 @@ TEST(HillOrientation, VisualiseOrientations) UInt16Array2D orientations = UInt16Array2D_Construct(blocks.blockCount.width, blocks.blockCount.height); HillOrientation_Detect(equalized, imgSize, &mask, &blocks, &orientations); + Int16Array3D_Destruct(&histogram); + Int16Array3D_Destruct(&smoothedHistogram); + UInt8Array2D_Destruct(&v); + BinaryMap_Destruct(&mask); + + print_orientations(orientations); UInt8Array2D outV = UInt8Array2D_Construct(imgSize.width, imgSize.height); for ( int i=0; i < orientations.sizeX; ++i ) { @@ -103,6 +109,8 @@ TEST(HillOrientation, VisualiseOrientations) } } pgm_write("../TestImages/Person1/output-Hamster-1-0.pgm", &outV); + + UInt8Array2D_Destruct(&outV); } TEST(HillOrientation, VisualisePixelMask) diff --git a/Sources/Tests/Extraction/Filters/runners/TestRunner_HillOrientation.c b/Sources/Tests/Extraction/Filters/runners/TestRunner_HillOrientation.c index 2ee7afb..7c25e92 100755 --- a/Sources/Tests/Extraction/Filters/runners/TestRunner_HillOrientation.c +++ b/Sources/Tests/Extraction/Filters/runners/TestRunner_HillOrientation.c @@ -3,7 +3,7 @@ TEST_GROUP_RUNNER(HillOrientation) { - RUN_TEST_CASE(HillOrientation, VisualiseOrientations); - RUN_TEST_CASE(HillOrientation, VisualisePixelMask); + //RUN_TEST_CASE(HillOrientation, VisualiseOrientations); + //RUN_TEST_CASE(HillOrientation, VisualisePixelMask); RUN_TEST_CASE(HillOrientation, ComputeOrientations); } diff --git a/Sources/Tests/all_tests.c b/Sources/Tests/all_tests.c index e9a5212..a734b80 100644 --- a/Sources/Tests/all_tests.c +++ b/Sources/Tests/all_tests.c @@ -10,7 +10,7 @@ static void RunAllTests(void) printf("\nOrientation tests\n"); RUN_TEST_GROUP(HillOrientation); - printf("\nOriented smoother tests\n"); + /*printf("\nOriented smoother tests\n"); RUN_TEST_GROUP(OrientedSmoother); printf("\nPoint tests\n"); @@ -50,7 +50,7 @@ static void RunAllTests(void) RUN_TEST_GROUP(DotRemover); printf("\nBestMatchSkipper tests\n"); - RUN_TEST_GROUP(BestMatchSkipper); + RUN_TEST_GROUP(BestMatchSkipper);*/ } int main(int argc, const char * argv[]) From 4bc6a3477ebcfe3fd709f0965b1e88c2131a4ea4 Mon Sep 17 00:00:00 2001 From: Arun Kumar Date: Fri, 6 Nov 2015 15:58:45 +0000 Subject: [PATCH 2/4] Free more memory in tests --- Sources/Tests/Extraction/Filters/Test_HillOrientation.c | 4 +++- Sources/Tests/all_tests.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Sources/Tests/Extraction/Filters/Test_HillOrientation.c b/Sources/Tests/Extraction/Filters/Test_HillOrientation.c index 26b3550..7936103 100755 --- a/Sources/Tests/Extraction/Filters/Test_HillOrientation.c +++ b/Sources/Tests/Extraction/Filters/Test_HillOrientation.c @@ -55,7 +55,8 @@ TEST(HillOrientation, VisualiseOrientations) Int16Array3D_Destruct(&smoothedHistogram); UInt8Array2D_Destruct(&v); BinaryMap_Destruct(&mask); - + FloatArray2D_Destruct(&equalized); + Equalizer_Destruct(&eq); print_orientations(orientations); UInt8Array2D outV = UInt8Array2D_Construct(imgSize.width, imgSize.height); @@ -110,6 +111,7 @@ TEST(HillOrientation, VisualiseOrientations) } pgm_write("../TestImages/Person1/output-Hamster-1-0.pgm", &outV); + UInt16Array2D_Destruct(&orientations); UInt8Array2D_Destruct(&outV); } diff --git a/Sources/Tests/all_tests.c b/Sources/Tests/all_tests.c index a734b80..e9a5212 100644 --- a/Sources/Tests/all_tests.c +++ b/Sources/Tests/all_tests.c @@ -10,7 +10,7 @@ static void RunAllTests(void) printf("\nOrientation tests\n"); RUN_TEST_GROUP(HillOrientation); - /*printf("\nOriented smoother tests\n"); + printf("\nOriented smoother tests\n"); RUN_TEST_GROUP(OrientedSmoother); printf("\nPoint tests\n"); @@ -50,7 +50,7 @@ static void RunAllTests(void) RUN_TEST_GROUP(DotRemover); printf("\nBestMatchSkipper tests\n"); - RUN_TEST_GROUP(BestMatchSkipper);*/ + RUN_TEST_GROUP(BestMatchSkipper); } int main(int argc, const char * argv[]) From 8041f527c81ce8a66b3c7408df6e58f72a95a159 Mon Sep 17 00:00:00 2001 From: Arun Kumar Date: Fri, 6 Nov 2015 15:59:45 +0000 Subject: [PATCH 3/4] Uncommented commented out tests --- .../Extraction/Filters/runners/TestRunner_HillOrientation.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Tests/Extraction/Filters/runners/TestRunner_HillOrientation.c b/Sources/Tests/Extraction/Filters/runners/TestRunner_HillOrientation.c index 7c25e92..2ee7afb 100755 --- a/Sources/Tests/Extraction/Filters/runners/TestRunner_HillOrientation.c +++ b/Sources/Tests/Extraction/Filters/runners/TestRunner_HillOrientation.c @@ -3,7 +3,7 @@ TEST_GROUP_RUNNER(HillOrientation) { - //RUN_TEST_CASE(HillOrientation, VisualiseOrientations); - //RUN_TEST_CASE(HillOrientation, VisualisePixelMask); + RUN_TEST_CASE(HillOrientation, VisualiseOrientations); + RUN_TEST_CASE(HillOrientation, VisualisePixelMask); RUN_TEST_CASE(HillOrientation, ComputeOrientations); } From a03365df409ef3981c72aec2f35ffa32eb31cfa5 Mon Sep 17 00:00:00 2001 From: Arun K Date: Mon, 9 Nov 2015 14:33:39 +0000 Subject: [PATCH 4/4] Added newline --- Sources/Tests/Extraction/Filters/Test_HillOrientation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Tests/Extraction/Filters/Test_HillOrientation.c b/Sources/Tests/Extraction/Filters/Test_HillOrientation.c index 292d65c..7d0a48b 100755 --- a/Sources/Tests/Extraction/Filters/Test_HillOrientation.c +++ b/Sources/Tests/Extraction/Filters/Test_HillOrientation.c @@ -198,4 +198,4 @@ TEST(HillOrientation, ComputeOrientations) Int16Array3D_Destruct(&smoothedHistogram); UInt16Array2D_Destruct(&orientations); Equalizer_Destruct(&eq); -} \ No newline at end of file +}