From 4fc6f8b0649e5462f4540ba46a6c246f4ef3b078 Mon Sep 17 00:00:00 2001 From: Jonathan Helmus Date: Wed, 24 Sep 2014 10:11:38 -0500 Subject: [PATCH 1/2] BUG: segmentation fault when unwrapping 3d image Unwrapping a 3D image using unwrap_phase no longer causes a segmentation fault when the wrap_around parameter is True for the middle dimension. --- skimage/restoration/unwrap_3d_ljmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skimage/restoration/unwrap_3d_ljmu.c b/skimage/restoration/unwrap_3d_ljmu.c index 88012f18..ebbf02ce 100644 --- a/skimage/restoration/unwrap_3d_ljmu.c +++ b/skimage/restoration/unwrap_3d_ljmu.c @@ -786,7 +786,7 @@ void verticalEDGEs(VOXELM *voxel, EDGE *edge, int volume_width, int volume_heig } voxel_pointer++; } - voxel_pointer += next_voxel + 1; + voxel_pointer += next_voxel; } } params->no_of_edges = no_of_edges; From 25653dc28822bb40d55cca43f73762e31a31782c Mon Sep 17 00:00:00 2001 From: Jonathan Helmus Date: Thu, 6 Nov 2014 21:03:14 -0600 Subject: [PATCH 2/2] TST: Unit test to check for 3d unwrap seg fault Added a unit test to check for bug in unwrap_phase which causes a segmentation fault when the middle dimension is connected. --- skimage/restoration/tests/test_unwrap.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/skimage/restoration/tests/test_unwrap.py b/skimage/restoration/tests/test_unwrap.py index fca63724..764e8b74 100644 --- a/skimage/restoration/tests/test_unwrap.py +++ b/skimage/restoration/tests/test_unwrap.py @@ -144,5 +144,12 @@ def test_invalid_input(): assert_raises(ValueError, unwrap_phase, np.zeros((1, 1)), 'False') +def test_unwrap_3d_middle_wrap_around(): + # Segmentation fault in 3D unwrap phase with middle dimension connected + # GitHub issue #1171 + image = np.zeros((20, 30, 40), dtype=np.float32) + unwrap = unwrap_phase(image, wrap_around=[False, True, False]) + assert np.all(unwrap == 0) + if __name__ == "__main__": run_module_suite()