From a5af3a6e9386602be76211551c4de2c465854463 Mon Sep 17 00:00:00 2001 From: Olivia Date: Fri, 28 Aug 2015 21:52:35 +0100 Subject: [PATCH 1/4] Updated the explanation of the watershed markers example. This fixes issue #1650 --- doc/examples/plot_marked_watershed.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/doc/examples/plot_marked_watershed.py b/doc/examples/plot_marked_watershed.py index 234e3818..f8a55b1f 100644 --- a/doc/examples/plot_marked_watershed.py +++ b/doc/examples/plot_marked_watershed.py @@ -6,7 +6,11 @@ Markers for watershed transform The watershed is a classical algorithm used for **segmentation**, that is, for separating different objects in an image. -Here a marker image is build from the region of low gradient inside the image. +Here a marker image is built from the region of low gradient inside the image. +In a gradient image, the areas of high values provide barriers which help to +segment the image. +Using markers on the lower values will ensure that the segmented objects are +found. See Wikipedia_ for more details on the algorithm. @@ -28,11 +32,12 @@ image = img_as_ubyte(data.camera()) # denoise image denoised = rank.median(image, disk(2)) -# find continuous region (low gradient) --> markers +# find continuous region (low gradient - where less than 10 for this image) --> markers +# disk(5) is used here to get a more smooth image markers = rank.gradient(denoised, disk(5)) < 10 markers = ndi.label(markers)[0] -#local gradient +# local gradient (disk(2) is used to keep edges thin) gradient = rank.gradient(denoised, disk(2)) # process the watershed @@ -43,13 +48,17 @@ fig, axes = plt.subplots(ncols=4, figsize=(8, 2.7)) ax0, ax1, ax2, ax3 = axes ax0.imshow(image, cmap=plt.cm.gray, interpolation='nearest') +ax0.set_title("Original") ax1.imshow(gradient, cmap=plt.cm.spectral, interpolation='nearest') +ax1.set_title("Local Gradient") ax2.imshow(markers, cmap=plt.cm.spectral, interpolation='nearest') +ax2.set_title("Markers") ax3.imshow(image, cmap=plt.cm.gray, interpolation='nearest') ax3.imshow(labels, cmap=plt.cm.spectral, interpolation='nearest', alpha=.7) +ax3.set_title("Segmented") for ax in axes: ax.axis('off') -fig.subplots_adjust(hspace=0.01, wspace=0.01, top=1, bottom=0, left=0, right=1) +fig.subplots_adjust(hspace=0.01, wspace=0.01, top=0.9, bottom=0, left=0, right=1) plt.show() From f63d942d9dc61ca75aae925aa4532c94305993db Mon Sep 17 00:00:00 2001 From: Olivia Date: Fri, 28 Aug 2015 22:11:55 +0100 Subject: [PATCH 2/4] Grammatical error/typo fixed --- doc/examples/plot_marked_watershed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/examples/plot_marked_watershed.py b/doc/examples/plot_marked_watershed.py index f8a55b1f..d94fb966 100644 --- a/doc/examples/plot_marked_watershed.py +++ b/doc/examples/plot_marked_watershed.py @@ -7,7 +7,7 @@ The watershed is a classical algorithm used for **segmentation**, that is, for separating different objects in an image. Here a marker image is built from the region of low gradient inside the image. -In a gradient image, the areas of high values provide barriers which help to +In a gradient image, the areas of high values provide barriers that help to segment the image. Using markers on the lower values will ensure that the segmented objects are found. From 2a0f29011f1614ce97e22ea3edd91ce53c2b6c63 Mon Sep 17 00:00:00 2001 From: David PS Date: Fri, 28 Aug 2015 22:30:21 +0100 Subject: [PATCH 3/4] fixed another typo --- doc/examples/plot_marked_watershed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/examples/plot_marked_watershed.py b/doc/examples/plot_marked_watershed.py index d94fb966..dafa311e 100644 --- a/doc/examples/plot_marked_watershed.py +++ b/doc/examples/plot_marked_watershed.py @@ -33,7 +33,7 @@ image = img_as_ubyte(data.camera()) denoised = rank.median(image, disk(2)) # find continuous region (low gradient - where less than 10 for this image) --> markers -# disk(5) is used here to get a more smooth image +# disk(5) is used here to get a smoother image markers = rank.gradient(denoised, disk(5)) < 10 markers = ndi.label(markers)[0] From 8ad487e059fb29ea80a598bd81d05b1948f9253d Mon Sep 17 00:00:00 2001 From: Olivia Date: Sat, 29 Aug 2015 09:54:09 +0100 Subject: [PATCH 4/4] Split comment into two rows --- doc/examples/plot_marked_watershed.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/examples/plot_marked_watershed.py b/doc/examples/plot_marked_watershed.py index d94fb966..3315595a 100644 --- a/doc/examples/plot_marked_watershed.py +++ b/doc/examples/plot_marked_watershed.py @@ -32,7 +32,8 @@ image = img_as_ubyte(data.camera()) # denoise image denoised = rank.median(image, disk(2)) -# find continuous region (low gradient - where less than 10 for this image) --> markers +# find continuous region (low gradient - +# where less than 10 for this image) --> markers # disk(5) is used here to get a more smooth image markers = rank.gradient(denoised, disk(5)) < 10 markers = ndi.label(markers)[0]