Skip to content

Commit

Permalink
markdown source builds
Browse files Browse the repository at this point in the history
Auto-generated via {sandpaper}
Source  : 877baa5
Branch  : main
Author  : Toby Hodges <[email protected]>
Time    : 2024-06-07 06:30:08 +0000
Message : Merge pull request #323 from bear-rsg/second-workshork-changes

Simpler solution for wellplate exercise
  • Loading branch information
actions-user committed Jun 7, 2024
1 parent f9e226e commit 921f797
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
10 changes: 5 additions & 5 deletions 02-image-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ Using array slicing, we can then address and assign a new value to that position

```python
zero = iio.imread(uri="data/eight.tif")
zero[2,1]= 1.0
zero[2, 1]= 1.0

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

```python
five = iio.imread(uri="data/eight.tif")
five[1,2]= 1.0
five[3,0]= 1.0
five[1, 2] = 1.0
five[3, 0] = 1.0
fig, ax = plt.subplots()
ax.imshow(five)
print(five)
Expand Down Expand Up @@ -400,7 +400,7 @@ three_colours = three_colours * 128

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

```python
fig, ax = plt.subplots()
ax.imshow(three_colours,cmap=plt.cm.gray)
ax.imshow(three_colours, cmap="gray")
```

![](fig/grayscale.png){alt='Image in greyscale'}
Expand Down
2 changes: 2 additions & 0 deletions 03-skimage-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import ipympl
import matplotlib.pyplot as plt
import numpy as np
import skimage as ski

%matplotlib widget
```

## Reading, displaying, and saving images
Expand Down
26 changes: 15 additions & 11 deletions 04-drawing.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,29 +462,33 @@ Your program should produce output that looks like this:

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

*Hint: You can load `data/centers.txt` using*:

```Python
# load the well coordinates as a NumPy array
centers = np.loadtxt("data/centers.txt", delimiter=" ")
```

::::::::::::::: solution

## Solution

```python
# load the well coordinates as a NumPy array
centers = np.loadtxt("data/centers.txt", delimiter=" ")

# read in original image
wellplate = iio.imread(uri="data/wellplate-01.jpg")
wellplate = np.array(wellplate)

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

# open and iterate through the centers file...
with open("data/centers.txt", "r") as center_file:
for line in center_file:
# ... getting the coordinates of each well...
coordinates = line.split()
cx = int(coordinates[0])
ry = int(coordinates[1])

# ... and drawing a circle on the mask
rr, cc = ski.draw.disk(center=(ry, cx), radius=16, shape=wellplate.shape[0:2])
mask[rr, cc] = False
# iterate through the well coordinates
for cx, ry in centers:
# draw a circle on the mask at the well center
rr, cc = ski.draw.disk(center=(ry, cx), radius=16, shape=wellplate.shape[:2])
mask[rr, cc] = False

# apply the mask
wellplate[mask] = 0
Expand Down
6 changes: 3 additions & 3 deletions md5sum.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"config.yaml" "101b3ac4b679126bb1f437306eb1b836" "site/built/config.yaml" "2023-04-25"
"index.md" "6e80c662708984307918adfad711e15f" "site/built/index.md" "2023-07-26"
"episodes/01-introduction.md" "9755639c515fdbf752422e2e59128f63" "site/built/01-introduction.md" "2023-07-26"
"episodes/02-image-basics.md" "7a99d30d6ef4a11b8766fef3096fd1ab" "site/built/02-image-basics.md" "2024-03-12"
"episodes/03-skimage-images.md" "9ab46078d049def7053e98f793fe426a" "site/built/03-skimage-images.md" "2024-03-12"
"episodes/04-drawing.md" "d52b45e266997d93e359c63d53822e9b" "site/built/04-drawing.md" "2024-03-12"
"episodes/02-image-basics.md" "d7e49ef016b308d80ae19d6a461855a8" "site/built/02-image-basics.md" "2024-06-07"
"episodes/03-skimage-images.md" "d7890de460222e8cdf461c76cba37692" "site/built/03-skimage-images.md" "2024-06-07"
"episodes/04-drawing.md" "48b42ee384b5b907d9f9b93ad0e98ce8" "site/built/04-drawing.md" "2024-06-07"
"episodes/05-creating-histograms.md" "4abbd123ba97d63c795398be6f6b7621" "site/built/05-creating-histograms.md" "2024-03-14"
"episodes/06-blurring.md" "131274433675bee650e218bd28830435" "site/built/06-blurring.md" "2024-03-12"
"episodes/07-thresholding.md" "4d34b89c8cd33cb6bb54103f805a39b9" "site/built/07-thresholding.md" "2024-03-12"
Expand Down

0 comments on commit 921f797

Please sign in to comment.