You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: episodes/07-thresholding.md
+18-6Lines changed: 18 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -347,18 +347,16 @@ plt.xlim(0, 1.0)
347
347
348
348
{alt='Grayscale histogram of the maize root image'}
349
349
350
-
The histogram has a significant peak around 0.2, and a second,
351
-
shallower peak near 0.6.
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.
352
351
Thus, this image is a good candidate for thresholding with Otsu's method.
353
352
The mathematical details of how this works are complicated (see
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.
The `&` operator above means that we have defined a logical AND statement. This combines the two tests of pixel intensities in the blurred image such that both must be true for a pixel's position to be set to `True` in the resulting mask.
668
+
669
+
| Result of `t < blurred_image`| Result of `blurred_image < 0.95 | Resulting value in `binary_mask`|
670
+
|----------|---------|---------|
671
+
| False | True | False |
672
+
| True | False | False |
673
+
| True | True | True |
674
+
675
+
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.
0 commit comments