Skip to content

Commit aad9cee

Browse files
committed
markdown source builds
Auto-generated via {sandpaper} Source : 5224322 Branch : main Author : Toby Hodges <tobyhodges@carpentries.org> Time : 2023-12-19 13:25:09 +0000 Message : Merge pull request #318 from bear-rsg/connected-components-changes Review changes
1 parent 23ef1d9 commit aad9cee

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

08-connected-components.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,14 @@ labeled_image, count = connected_components(filename="data/shapes-01.jpg", sigma
316316

317317
fig, ax = plt.subplots()
318318
plt.imshow(labeled_image)
319-
plt.axis("off")
319+
plt.axis("off");
320320
```
321321

322322
:::::::::::::::: spoiler
323323

324324
## Do you see an empty image?
325325

326-
If you are using an old version of Matplotlib you might get a warning
326+
If you are using an older version of Matplotlib you might get a warning
327327
`UserWarning: Low image data range; displaying image with stretched contrast.`
328328
or just see a visually empty image.
329329

@@ -371,6 +371,16 @@ Alternatively we could convert the image to RGB and then display it.
371371

372372
:::::::::::::::::::::::::
373373

374+
::::::::::::::::::::::::::::::::::::::::: callout
375+
376+
## Suppressing outputs in Jupyter Notebooks
377+
378+
We just used `plt.axis("off");` to hide the axis from the image for a visually cleaner figure. The
379+
semicolon is added to supress the output(s) of the statement, in this [case](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.axis.html)
380+
the axis limits. This is specific to Jupyter Notebooks.
381+
382+
::::::::::::::::::::::::::::::::::::::::::::::::::
383+
374384
We can use the function `ski.color.label2rgb()`
375385
to convert the 32-bit grayscale labeled image to standard RGB colour
376386
(recall that we already used the `ski.color.rgb2gray()` function
@@ -385,7 +395,7 @@ colored_label_image = ski.color.label2rgb(labeled_image, bg_label=0)
385395

386396
fig, ax = plt.subplots()
387397
plt.imshow(colored_label_image)
388-
plt.axis("off")
398+
plt.axis("off");
389399
```
390400

391401
![](fig/shapes-01-labeled.png){alt='Labeled objects'}
@@ -407,7 +417,7 @@ How does changing the `sigma` and `threshold` values influence the result?
407417
## Solution
408418

409419
As you might have guessed, the return value `count` already
410-
contains the number of found objects in the image. So it can simply be printed
420+
contains the number of objects found in the image. So it can simply be printed
411421
with
412422

413423
```python
@@ -733,7 +743,7 @@ colored_label_image = ski.color.label2rgb(labeled_image, bg_label=0)
733743

734744
fig, ax = plt.subplots()
735745
plt.imshow(colored_label_image)
736-
plt.axis("off")
746+
plt.axis("off");
737747

738748
print("Found", count, "objects in the image.")
739749
```
@@ -786,7 +796,7 @@ fig, ax = plt.subplots()
786796
im = plt.imshow(colored_area_image)
787797
cbar = fig.colorbar(im, ax=ax, shrink=0.85)
788798
cbar.ax.set_title("Area")
789-
plt.axis("off")
799+
plt.axis("off");
790800
```
791801

792802
![](fig/shapes-01-objects-coloured-by-area.png){alt='Objects colored by area'}

md5sum.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"episodes/05-creating-histograms.md" "59c07192c0a6217e8a42d3e7365025f9" "site/built/05-creating-histograms.md" "2023-12-08"
1111
"episodes/06-blurring.md" "8d109bb4c49f27f54857f6d35b4c6b9a" "site/built/06-blurring.md" "2023-12-08"
1212
"episodes/07-thresholding.md" "bc0b3a64255ef9dd359d4cf3188aba83" "site/built/07-thresholding.md" "2023-12-15"
13-
"episodes/08-connected-components.md" "ffea5032d5ede5aa12673c83f9c62e97" "site/built/08-connected-components.md" "2023-12-15"
13+
"episodes/08-connected-components.md" "c4b727de6f6f5ea4f8ef5467759c85bd" "site/built/08-connected-components.md" "2023-12-19"
1414
"episodes/09-challenges.md" "655bdca8cab5d28dc6b2c2e9275aaecc" "site/built/09-challenges.md" "2023-12-15"
1515
"instructors/instructor-notes.md" "b1c166a544eb4b9b91f3ac8f2dafd549" "site/built/instructor-notes.md" "2023-05-12"
1616
"learners/discuss.md" "ad762c335f99400dc2cd1a8aad36bdbd" "site/built/discuss.md" "2023-07-26"

0 commit comments

Comments
 (0)