Skip to content

Commit 81b8d28

Browse files
committed
tidying PR
1 parent 31d8dbe commit 81b8d28

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

episodes/07-thresholding.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,14 +347,27 @@ plt.xlim(0, 1.0)
347347

348348
![](fig/maize-root-cluster-histogram.png){alt='Grayscale histogram of the maize root image'}
349349

350-
The histogram has a significant peak around 0.2 and then a broader "hill" around 0.6 followed by a smaller peak near 1.0. Looking at the grayscale image, we can identify the lower peak at 0.2 as the background and the larger pixel values as the foreground, but it is not so obvious what the threshold should be.
350+
The histogram has a significant peak around 0.2 and then a broader "hill" around 0.6 followed by a
351+
smaller peak near 1.0. Looking at the grayscale image, we can identify the lower peak at 0.2 as the
352+
background and the broader peak as the foreground.
351353
Thus, this image is a good candidate for thresholding with Otsu's method.
352354
The mathematical details of how this works are complicated (see
353355
[the scikit-image documentation](https://scikit-image.org/docs/dev/api/skimage.filters.html#threshold-otsu)
354356
if you are interested),
355-
but the outcome is that Otsu's method finds a threshold value between the two peaks of a grayscale histogram which might correspond well to the foreground and background depending the data and application.
357+
but the outcome is that Otsu's method finds a threshold value between the two peaks of a grayscale
358+
histogram which might correspond well to the foreground and background depending on the data and
359+
application.
360+
356361
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: instructor
357-
The histogram of the maize root image may prompt questions from learners about the interpretation of the peaks and the broader region around 0.6. The focus here is on the separation of background and foreground pixel values. We note that Otsu's method does not work well for the image with the shapes used earlier in this episode, as the foreground pixel values are more distributed. These examples could be augmented by a discussion of unimodal, bimodal, and multimodal histograms. While these points can lead to fruitful discussions, the text in this episode attempts to reduce cognitive load and deliberately simplifies the discussion.
362+
363+
The histogram of the maize root image may prompt questions from learners about the interpretation
364+
of the peaks and the broader region around 0.6. The focus here is on the separation of background
365+
and foreground pixel values. We note that Otsu's method does not work well
366+
for the image with the shapes used earlier in this episode, as the foreground pixel values are more
367+
distributed. These examples could be augmented by a discussion of unimodal, bimodal, and multimodal
368+
histograms. While these points can lead to fruitful discussions, the text in this episode attempts
369+
to reduce cognitive load and deliberately simplifies the discussion.
370+
358371
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
359372

360373
The `ski.filters.threshold_otsu()` function can be used to determine
@@ -632,7 +645,7 @@ def enhanced_root_mass(filename, sigma):
632645
t = ski.filters.threshold_otsu(blurred_image[binary_mask])
633646

634647
# update binary mask to identify pixels which are both less than 0.95 and greater than t
635-
binary_mask = binary_mask & (blurred_image > t)
648+
binary_mask = (blurred_image < 0.95) & (blurred_image > t)
636649

637650
# determine root mass ratio
638651
root_pixels = np.count_nonzero(binary_mask)
@@ -674,6 +687,7 @@ The `&` operator above means that we have defined a logical AND statement. This
674687
Knowing how to construct this kind of logical operation can be very helpful in image processing. The University of Minnesota Library's [guide to Boolean operators](https://libguides.umn.edu/BooleanOperators) is a good place to start if you want to learn more.
675688

676689
::::::::::::::::::::::::::::::::::::::::::::::::::
690+
677691
Here are the binary images produced by the additional thresholding.
678692
Note that we have not completely removed the offending white pixels.
679693
Outlines still remain.

0 commit comments

Comments
 (0)