Skip to content

Commit 2b4a521

Browse files
authored
Merge pull request #312 from bear-rsg/histogram-episode-corrections
Histogram episode corrections
2 parents 333009e + e025cad commit 2b4a521

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

episodes/05-creating-histograms.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ plt.imshow(plant_seedling, cmap="gray")
7373
Again, we use the `iio.imread()` function to load our image.
7474
Then, we convert the grayscale image of integer dtype, with 0-255 range, into
7575
a floating-point one with 0-1 range, by calling the function
76-
`ski.util.img_as_float`.
77-
We will keep working with images in the value range 0 to 1 in this lesson.
76+
`ski.util.img_as_float`. We can also calculate histograms for 8 bit images as we will see in the
77+
subsequent exercises.
7878

7979
We now use the function `np.histogram` to compute the histogram of our image
8080
which, after all, is a NumPy array:
@@ -90,7 +90,7 @@ the 256 possible values in the grayscale image.
9090

9191
The parameter `range` is the range of values each of the pixels in the image can have.
9292
Here, we pass 0 and 1,
93-
which is the value range of our input image after transforming it to grayscale.
93+
which is the value range of our input image after conversion to floating-point.
9494

9595
The first output of the `np.histogram` function is a one-dimensional NumPy array,
9696
with 256 rows and one column,
@@ -351,10 +351,10 @@ with the
351351
function call,
352352
and then add a histogram line of the correct colour to the plot with the
353353

354-
`plt.plot(bin_edges[0:-1], histogram, color=c)`
354+
`plt.plot(bin_edges[0:-1], histogram, color=color)`
355355

356356
function call.
357-
Note the use of our loop variables, `channel_id` and `c`.
357+
Note the use of our loop variables, `channel_id` and `color`.
358358

359359
Finally we label our axes and display the histogram, shown here:
360360

@@ -411,9 +411,9 @@ mask[circle] = 1
411411

412412
# just for display:
413413
# make a copy of the image, call it masked_image, and
414-
# use np.logical_not() and indexing to apply the mask to it
415-
masked_img = wellplate[:]
416-
masked_img[np.logical_not(mask)] = 0
414+
# zero values where mask is False
415+
masked_img = np.array(wellplate)
416+
masked_img[~mask] = 0
417417

418418
# create a new figure and display masked_img, to verify the
419419
# validity of your mask

0 commit comments

Comments
 (0)