Skip to content

Commit

Permalink
markdown source builds
Browse files Browse the repository at this point in the history
Auto-generated via `{sandpaper}`
Source  : 007126d
Branch  : main
Author  : Kimberly Meechan <[email protected]>
Time    : 2024-11-18 09:29:18 +0000
Message : Merge pull request datacarpentry#331 from datacarpentry/update/workflows

Update Workflows to Version 0.16.6
  • Loading branch information
actions-user committed Nov 24, 2024
1 parent 6170e57 commit 44c5f25
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 27 deletions.
18 changes: 12 additions & 6 deletions 02-image-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ as numeric abstractions, approximations of what we see with our eyes in the real
Before we begin to learn how to process images with Python programs,
we need to spend some time understanding how these abstractions work.

::::::::::::::::::::::::::::::::::::::::: callout

Feel free to make use of the [available cheat-sheet](./files/cheatsheet.html) as a guide for the rest of the course material. View it online, share it, or print the [PDF](./files/cheatsheet.pdf)!

::::::::::::::::::::::::::::::::::::::::::::::::::

## Pixels

It is important to realise that images are stored as rectangular arrays
Expand Down Expand Up @@ -287,7 +293,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 +368,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 +406,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,12 +442,12 @@ 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'}

Above we have exactly the same underying data matrix, but in greyscale.
Above we have exactly the same underlying data matrix, but in greyscale.
Zero maps to black, 255 maps to white, and 128 maps to medium grey.
Here we only have a single channel in the data and utilize a grayscale color map
to represent the luminance, or intensity of the data and correspondingly
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
2 changes: 1 addition & 1 deletion 05-creating-histograms.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ ax.set_ylabel("pixel count")
- In many cases, we can load images in grayscale by passing the `mode="L"` argument to the `iio.imread()` function.
- We can create histograms of images with the `np.histogram` function.
- We can display histograms using `ax.plot()` with the `bin_edges` and `histogram` values returned by `np.histogram()`.
- The plot can be customised using `set_xlabel()`, `set_ylabel()`, `set_xlim()`, `set_ylim()`, and `set_title()`.
- The plot can be customised using `ax.set_xlabel()`, `ax.set_ylabel()`, `ax.set_xlim()`, `ax.set_ylim()`, and `ax.set_title()`.
- We can separate the colour channels of an RGB image using slicing operations and create histograms for each colour channel separately.

::::::::::::::::::::::::::::::::::::::::::::::::::
2 changes: 1 addition & 1 deletion 06-blurring.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ A high-pass filter will retain the smaller details in an image,
filtering out the larger ones.
A low-pass filter retains the larger features,
analogous to what's left behind by a physical filter mesh.
*High-* and \*low-\*pass, here,
*High-* and *low*-pass, here,
refer to high and low *spatial frequencies* in the image.
Details associated with high spatial frequencies are small,
a lot of these features would fit across an image.
Expand Down
2 changes: 1 addition & 1 deletion 08-connected-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ The labels of the objects are also returned by `ski.measure.regionprops`.
We have already seen that we can create boolean arrays using comparison operators.
Here we can use `object_areas > min_area`
to produce an array that has the same dimension as `object_labels`.
It can then used to select the labels of objects whose area is
It can then be used to select the labels of objects whose area is
greater than `min_area` by indexing:

```python
Expand Down
34 changes: 34 additions & 0 deletions files/assets/dc-logo-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added files/assets/fixed_cells_masked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions files/cheatsheet.html

Large diffs are not rendered by default.

Binary file added files/cheatsheet.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions instructor-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ to share your experience with the lesson Maintainers.
- Be aware that learners might get surprising results in the *Keeping only low intensity pixels* exercise, if `plt.imshow` is called without the `vmax` parameter.
A detailed explanation is given in the *Plotting single channel images (cmap, vmin, vmax)* callout box.

## Additional resources

- A cheat-sheet with graphics illustrating some concepts in this lesson is available:
- [Cheat-sheet HTML for viewing in browser](../episodes/files/cheatsheet.html).
- [PDF version for printing](../episodes/files/cheatsheet.pdf).


## Questions from Learners

Expand Down
14 changes: 7 additions & 7 deletions md5sum.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"config.yaml" "101b3ac4b679126bb1f437306eb1b836" "site/built/config.yaml" "2023-04-25"
"index.md" "6e80c662708984307918adfad711e15f" "site/built/index.md" "2024-01-28"
"episodes/01-introduction.md" "9755639c515fdbf752422e2e59128f63" "site/built/01-introduction.md" "2024-01-28"
"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/05-creating-histograms.md" "6feadaf21b14e224b83dccf4b12b464c" "site/built/05-creating-histograms.md" "2024-03-12"
"episodes/06-blurring.md" "131274433675bee650e218bd28830435" "site/built/06-blurring.md" "2024-03-12"
"episodes/02-image-basics.md" "f1c4a800b8213f11b6e2efbe40f501ab" "site/built/02-image-basics.md" "2024-11-24"
"episodes/03-skimage-images.md" "d7890de460222e8cdf461c76cba37692" "site/built/03-skimage-images.md" "2024-11-24"
"episodes/04-drawing.md" "48b42ee384b5b907d9f9b93ad0e98ce8" "site/built/04-drawing.md" "2024-11-24"
"episodes/05-creating-histograms.md" "4abbd123ba97d63c795398be6f6b7621" "site/built/05-creating-histograms.md" "2024-11-24"
"episodes/06-blurring.md" "894ff33379584a8ee777f779564d5b01" "site/built/06-blurring.md" "2024-11-24"
"episodes/07-thresholding.md" "4d34b89c8cd33cb6bb54103f805a39b9" "site/built/07-thresholding.md" "2024-03-12"
"episodes/08-connected-components.md" "79495641132337de72f9df87ce5a2d21" "site/built/08-connected-components.md" "2024-03-12"
"episodes/08-connected-components.md" "f599af69b770c7234a4e7d4a06a7f6dd" "site/built/08-connected-components.md" "2024-11-24"
"episodes/09-challenges.md" "3e95485b1bae2c37538830225ea26598" "site/built/09-challenges.md" "2024-03-12"
"instructors/instructor-notes.md" "b1c166a544eb4b9b91f3ac8f2dafd549" "site/built/instructor-notes.md" "2024-01-28"
"instructors/instructor-notes.md" "e8e378a5dfaec7b2873d788be85003ce" "site/built/instructor-notes.md" "2024-11-24"
"learners/discuss.md" "ad762c335f99400dc2cd1a8aad36bdbd" "site/built/discuss.md" "2024-01-28"
"learners/edge-detection.md" "fdbcee7436e104e6587e1cb40cd37d18" "site/built/edge-detection.md" "2024-01-28"
"learners/prereqs.md" "7ca883d3d01d18c98ce7524ed297e56c" "site/built/prereqs.md" "2024-01-28"
Expand Down

0 comments on commit 44c5f25

Please sign in to comment.