Skip to content

Commit 2642940

Browse files
committed
updates
1 parent f78936e commit 2642940

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

episodes/02-image-basics.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ Using array slicing, we can then address and assign a new value to that position
287287

288288
```python
289289
zero = iio.imread(uri="data/eight.tif")
290-
zero[2,1]= 1.0
290+
zero[2, 1]= 1.0
291291

292292
# The following line of code creates a new figure for imshow to use in displaying our output.
293293
fig, ax = plt.subplots()
@@ -362,8 +362,8 @@ There are many possible solutions, but one method would be . . .
362362

363363
```python
364364
five = iio.imread(uri="data/eight.tif")
365-
five[1,2]= 1.0
366-
five[3,0]= 1.0
365+
five[1, 2] = 1.0
366+
five[3, 0] = 1.0
367367
fig, ax = plt.subplots()
368368
ax.imshow(five)
369369
print(five)
@@ -400,7 +400,7 @@ three_colours = three_colours * 128
400400

401401
# set the middle row (index 2) to the value of 255.,
402402
# so you end up with the values 0., 128., and 255.
403-
three_colours[2,:] = 255.
403+
three_colours[2, :] = 255.
404404
fig, ax = plt.subplots()
405405
ax.imshow(three_colours)
406406
print(three_colours)
@@ -436,7 +436,7 @@ a mapped continuum of intensities: greyscale.
436436

437437
```python
438438
fig, ax = plt.subplots()
439-
ax.imshow(three_colours,cmap=plt.cm.gray)
439+
ax.imshow(three_colours, cmap="gray")
440440
```
441441

442442
![](fig/grayscale.png){alt='Image in greyscale'}

episodes/03-skimage-images.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import ipympl
3131
import matplotlib.pyplot as plt
3232
import numpy as np
3333
import skimage as ski
34+
35+
%matplotlib widget
3436
```
3537

3638
## Reading, displaying, and saving images

episodes/04-drawing.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -462,29 +462,33 @@ Your program should produce output that looks like this:
462462

463463
![](fig/wellplate-01-masked.jpg){alt='Masked 96-well plate'}
464464

465+
*Hint: You can load `data/centers.txt` using*:
466+
467+
```Python
468+
# load the well coordinates as a NumPy array
469+
centers = np.loadtxt("data/centers.txt", delimiter=" ")
470+
```
471+
465472
::::::::::::::: solution
466473

467474
## Solution
468475

469476
```python
477+
# load the well coordinates as a NumPy array
478+
centers = np.loadtxt("data/centers.txt", delimiter=" ")
479+
470480
# read in original image
471481
wellplate = iio.imread(uri="data/wellplate-01.jpg")
472482
wellplate = np.array(wellplate)
473483

474484
# create the mask image
475485
mask = np.ones(shape=wellplate.shape[0:2], dtype="bool")
476486

477-
# open and iterate through the centers file...
478-
with open("data/centers.txt", "r") as center_file:
479-
for line in center_file:
480-
# ... getting the coordinates of each well...
481-
coordinates = line.split()
482-
cx = int(coordinates[0])
483-
ry = int(coordinates[1])
484-
485-
# ... and drawing a circle on the mask
486-
rr, cc = ski.draw.disk(center=(ry, cx), radius=16, shape=wellplate.shape[0:2])
487-
mask[rr, cc] = False
487+
# iterate through the well coordinates
488+
for cx, ry in centers:
489+
# draw a circle on the mask at the well center
490+
rr, cc = ski.draw.disk(center=(ry, cx), radius=16, shape=wellplate.shape[:2])
491+
mask[rr, cc] = False
488492

489493
# apply the mask
490494
wellplate[mask] = 0

0 commit comments

Comments
 (0)