Skip to content

Commit 6900150

Browse files
authored
Merge pull request #193 from quist00/pr/thresholding_solution_tweak
alter solution of "More practice with simple thresholding" so output matches displayed image
2 parents dfc1e39 + e330aa8 commit 6900150

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

episodes/07-thresholding.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ plt.show()
221221
> > The histogram for the `data/shapes-02.jpg` image can be shown with
222222
> >
223223
> > ~~~
224-
> > image = skimage.io.imread("data/shapes-02.jpg", as_gray=True)
225-
> > histogram, bin_edges = np.histogram(image, bins=256, range=(0.0, 1.0))
224+
> > gray_image = skimage.io.imread("data/shapes-02.jpg", as_gray=True)
225+
> > histogram, bin_edges = np.histogram(gray_image, bins=256, range=(0.0, 1.0))
226226
> >
227227
> > fig, ax = plt.subplots()
228228
> > plt.plot(bin_edges[0:-1], histogram)
@@ -255,7 +255,7 @@ plt.show()
255255
> > Here are the commands to create and view the binary mask
256256
> > ~~~
257257
> > t = 0.5
258-
> > binary_mask = image < t
258+
> > binary_mask = gray_image > t
259259
> >
260260
> > fig, ax = plt.subplots()
261261
> > plt.imshow(binary_mask, cmap='gray')
@@ -267,6 +267,7 @@ plt.show()
267267
> >
268268
> > And here are the commands to apply the mask and view the thresholded image
269269
> > ~~~
270+
> > image = skimage.io.imread("data/shapes-02.jpg")
270271
> > selection = np.zeros_like(image)
271272
> > selection[binary_mask] = image[binary_mask]
272273
> >

0 commit comments

Comments
 (0)