Skip to content

Commit c875bd1

Browse files
author
Marco Dalla Vecchia
committed
moved all dark images to from data to fig folder, to leave the data directory clean
1 parent 17e9308 commit c875bd1

29 files changed

Lines changed: 42 additions & 42 deletions

episodes/03-skimage-images.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ Images may appear the same size in jupyter,
191191
but you can see the size difference by comparing the scales for each.
192192
You can also see the difference in file storage size on disk by
193193
hovering your mouse cursor over the original
194-
and the new files in the Jupyter file browser, using `ls -l` in your shell
194+
and the new files in the Jupyter file browser, using `ls -l` in your shell
195195
(`dir` with Windows PowerShell), or viewing file sizes in the OS file browser if it is configured so.
196196

197197
::::::::::::::: solution
@@ -240,7 +240,7 @@ Suppose we are interested in this maize root cluster image.
240240
We want to be able to focus our program's attention on the roots themselves,
241241
while ignoring the black background.
242242

243-
![](data/maize-root-cluster.jpg){alt='Root cluster image'}
243+
![](fig/maize-root-cluster.jpg){alt='Root cluster image'}
244244

245245
Since the image is stored as an array of numbers,
246246
we can simply look through the array for pixel colour values that are
@@ -379,9 +379,9 @@ the low intensity pixels while changing the high intensity ones.
379379

380380
The file `data/sudoku.png` is an RGB image of a sudoku puzzle:
381381

382-
![](data/sudoku.png){alt='Su-Do-Ku puzzle'}
382+
![](fig/sudoku.png){alt='Su-Do-Ku puzzle'}
383383

384-
Your task is to load the image in grayscale format and turn all of
384+
Your task is to load the image in grayscale format and turn all of
385385
the bright pixels in the image to a
386386
light gray colour. In other words, mask the bright pixels that have
387387
a pixel value greater than, say, 192 and set their value to 192 (the
@@ -392,15 +392,15 @@ range 0-255 of an 8-bit pixel). The results should look like this:
392392

393393
*Hint: the `cmap`, `vmin`, and `vmax` parameters of `matplotlib.pyplot.imshow`
394394
will be needed to display the modified image as desired. See the [Matplotlib
395-
documentation](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.imshow.html)
395+
documentation](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.imshow.html)
396396
for more details on `cmap`, `vmin`, and `vmax`.*
397397

398398
::::::::::::::: solution
399399

400400
## Solution
401401

402-
First, load the image file `data/sudoku.png` as a grayscale image.
403-
Note we may want to create a copy of the image array to avoid modifying our original variable and
402+
First, load the image file `data/sudoku.png` as a grayscale image.
403+
Note we may want to create a copy of the image array to avoid modifying our original variable and
404404
also because `imageio.v3.imread` sometimes returns a non-writeable image.
405405

406406
```python
@@ -465,11 +465,11 @@ Consider this image of a whiteboard, and suppose that we want to create a
465465
sub-image with just the portion that says "odd + even = odd," along with the
466466
red box that is drawn around the words.
467467

468-
![](data/board.jpg){alt='Whiteboard image'}
468+
![](fig/board.jpg){alt='Whiteboard image'}
469469

470-
Using `matplotlib.pyplot.imshow`
470+
Using `matplotlib.pyplot.imshow`
471471
we can determine the coordinates of the corners of the area we wish to extract
472-
by hovering the mouse near the points of interest and noting the coordinates
472+
by hovering the mouse near the points of interest and noting the coordinates
473473
(remember to run `%matplotlib widget` first if you haven't already).
474474
If we do that, we might settle on a rectangular
475475
area with an upper-left coordinate of *(135, 60)*

episodes/04-drawing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ Copy that image to your computer, write some code to make a mask,
393393
and apply it to select the part of the image containing your object.
394394
For example, here is an image of a remote control:
395395

396-
![](data/remote-control.jpg){alt='Remote control image'}
396+
![](fig/remote-control.jpg){alt='Remote control image'}
397397

398398
And, here is the end result of a program masking out everything but the remote:
399399

@@ -446,7 +446,7 @@ fig, ax = plt.subplots()
446446
ax.imshow(wellplate)
447447
```
448448

449-
![](data/wellplate-01.jpg){alt='96-well plate'}
449+
![](fig/wellplate-01.jpg){alt='96-well plate'}
450450

451451
Suppose that we are interested in the colours of the solutions in each of the wells.
452452
We *do not* care about the colour of the rest of the image,

episodes/05-creating-histograms.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ and histograms are also quite handy as a preparatory step before performing
5252
We will start with grayscale images,
5353
and then move on to colour images.
5454
We will use this image of a plant seedling as an example:
55-
![](data/plant-seedling.jpg){alt='Plant seedling'}
55+
![](fig/plant-seedling.jpg){alt='Plant seedling'}
5656

5757
Here we load the image in grayscale instead of full colour, and display it:
5858

episodes/06-blurring.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ fig, ax = plt.subplots()
276276
ax.imshow(image)
277277
```
278278

279-
![](data/gaussian-original.png){alt='Original image'}
279+
![](fig/gaussian-original.png){alt='Original image'}
280280

281281
Next, we apply the gaussian blur:
282282

@@ -331,8 +331,8 @@ ax.imshow(blurred)
331331

332332
## Visualising Blurring
333333

334-
Somebody said once "an image is worth a thousand words".
335-
What is actually happening to the image pixels when we apply blurring may be
334+
Somebody said once "an image is worth a thousand words".
335+
What is actually happening to the image pixels when we apply blurring may be
336336
difficult to grasp. Let's now visualise the effects of blurring from a different
337337
perspective.
338338

@@ -430,18 +430,18 @@ but can be viewed by following the links in the captions.
430430

431431

432432
![
433-
A 3D plot of pixel intensities across the whole Petri dish image before blurring.
434-
[Explore how this plot was created with matplotlib](https://gist.github.com/chbrandt/63ba38142630a0586ba2a13eabedf94b).
433+
A 3D plot of pixel intensities across the whole Petri dish image before blurring.
434+
[Explore how this plot was created with matplotlib](https://gist.github.com/chbrandt/63ba38142630a0586ba2a13eabedf94b).
435435
Image credit: [Carlos H Brandt](https://github.com/chbrandt/).
436436
](fig/3D_petri_before_blurring.png){
437437
alt='3D surface plot showing pixel intensities across the whole example Petri dish image before blurring'
438438
}
439439

440440
![
441-
A 3D plot of pixel intensities after Gaussian blurring of the Petri dish image.
442-
Note the 'smoothing' effect on the pixel intensities of the colonies in the image,
443-
and the 'flattening' of the background noise at relatively low pixel intensities throughout the image.
444-
[Explore how this plot was created with matplotlib](https://gist.github.com/chbrandt/63ba38142630a0586ba2a13eabedf94b).
441+
A 3D plot of pixel intensities after Gaussian blurring of the Petri dish image.
442+
Note the 'smoothing' effect on the pixel intensities of the colonies in the image,
443+
and the 'flattening' of the background noise at relatively low pixel intensities throughout the image.
444+
[Explore how this plot was created with matplotlib](https://gist.github.com/chbrandt/63ba38142630a0586ba2a13eabedf94b).
445445
Image credit: [Carlos H Brandt](https://github.com/chbrandt/).
446446
](fig/3D_petri_after_blurring.png){
447447
alt='3D surface plot illustrating the smoothing effect on pixel intensities across the whole example Petri dish image after blurring'

episodes/07-thresholding.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fig, ax = plt.subplots()
6868
ax.imshow(shapes01)
6969
```
7070

71-
![](data/shapes-01.jpg){alt='Image with geometric shapes on white background' .image-with-shadow}
71+
![](fig/shapes-01.jpg){alt='Image with geometric shapes on white background' .image-with-shadow}
7272

7373
Now suppose we want to select only the shapes from the image.
7474
In other words, we want to leave the pixels belonging to the shapes "on,"
@@ -214,7 +214,7 @@ ax.imshow(selection)
214214
Now, it is your turn to practice. Suppose we want to use simple thresholding
215215
to select only the coloured shapes (in this particular case we consider grayish to be a colour, too) from the image `data/shapes-02.jpg`:
216216

217-
![](data/shapes-02.jpg){alt='Another image with geometric shapes on white background'}
217+
![](fig/shapes-02.jpg){alt='Another image with geometric shapes on white background'}
218218

219219
First, plot the grayscale histogram as in the [Creating
220220
Histogram](05-creating-histograms.md) episode and
@@ -324,7 +324,7 @@ fig, ax = plt.subplots()
324324
ax.imshow(maize_roots)
325325
```
326326

327-
![](data/maize-root-cluster.jpg){alt='Image of a maize root'}
327+
![](fig/maize-root-cluster.jpg){alt='Image of a maize root'}
328328

329329
We use Gaussian blur with a sigma of 1.0 to denoise the root image.
330330
Let us look at the grayscale histogram of the denoised image.
@@ -348,25 +348,25 @@ ax.set_xlim(0, 1.0)
348348

349349
![](fig/maize-root-cluster-histogram.png){alt='Grayscale histogram of the maize root image'}
350350

351-
The histogram has a significant peak around 0.2 and then a broader "hill" around 0.6 followed by a
351+
The histogram has a significant peak around 0.2 and then a broader "hill" around 0.6 followed by a
352352
smaller peak near 1.0. Looking at the grayscale image, we can identify the peak at 0.2 with the
353353
background and the broader peak with the foreground.
354354
Thus, this image is a good candidate for thresholding with Otsu's method.
355355
The mathematical details of how this works are complicated (see
356356
[the scikit-image documentation](https://scikit-image.org/docs/dev/api/skimage.filters.html#threshold-otsu)
357357
if you are interested),
358358
but the outcome is that Otsu's method finds a threshold value between the two peaks of a grayscale
359-
histogram which might correspond well to the foreground and background depending on the data and
359+
histogram which might correspond well to the foreground and background depending on the data and
360360
application.
361361

362362
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: instructor
363363

364-
The histogram of the maize root image may prompt questions from learners about the interpretation
365-
of the peaks and the broader region around 0.6. The focus here is on the separation of background
366-
and foreground pixel values. We note that Otsu's method does not work well
367-
for the image with the shapes used earlier in this episode, as the foreground pixel values are more
364+
The histogram of the maize root image may prompt questions from learners about the interpretation
365+
of the peaks and the broader region around 0.6. The focus here is on the separation of background
366+
and foreground pixel values. We note that Otsu's method does not work well
367+
for the image with the shapes used earlier in this episode, as the foreground pixel values are more
368368
distributed. These examples could be augmented with a discussion of unimodal, bimodal, and multimodal
369-
histograms. While these points can lead to fruitful considerations, the text in this episode attempts
369+
histograms. While these points can lead to fruitful considerations, the text in this episode attempts
370370
to reduce cognitive load and deliberately simplifies the discussion.
371371

372372
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@@ -636,10 +636,10 @@ def enhanced_root_mass(filename, sigma):
636636

637637
# perform binary thresholding to mask the white label and circle
638638
binary_mask = blurred_image < 0.95
639-
639+
640640
# perform automatic thresholding using only the pixels with value True in the binary mask
641641
t = ski.filters.threshold_otsu(blurred_image[binary_mask])
642-
642+
643643
# update binary mask to identify pixels which are both less than 0.95 and greater than t
644644
binary_mask = (blurred_image < 0.95) & (blurred_image > t)
645645

@@ -677,7 +677,7 @@ The `&` operator above means that we have defined a logical AND statement. This
677677
| False | True | False |
678678
| True | False | False |
679679
| True | True | True |
680-
680+
681681
Knowing how to construct this kind of logical operation can be very helpful in image processing. The University of Minnesota Library's [guide to Boolean operators](https://libguides.umn.edu/BooleanOperators) is a good place to start if you want to learn more.
682682

683683
::::::::::::::::::::::::::::::::::::::::::::::::::

episodes/08-connected-components.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ we have covered dividing an image into foreground and background pixels.
2727
In the shapes example image,
2828
we considered the coloured shapes as foreground *objects* on a white background.
2929

30-
![](data/shapes-01.jpg){alt='Original shapes image' .image-with-shadow}
30+
![](fig/shapes-01.jpg){alt='Original shapes image' .image-with-shadow}
3131

3232
In thresholding we went from the original image to this version:
3333

@@ -357,15 +357,15 @@ Those are really big numbers.
357357
From this available space we only use the range from `0` to `11`.
358358
When showing this image in the viewer,
359359
it may squeeze the complete range into 256 gray values.
360-
Therefore, the range of our numbers does not produce any visible variation. One way to rectify this
360+
Therefore, the range of our numbers does not produce any visible variation. One way to rectify this
361361
is to explicitly specify the data range we want the colormap to cover:
362362

363363
```python
364364
fig, ax = plt.subplots()
365365
ax.imshow(labeled_image, vmin=np.min(labeled_image), vmax=np.max(labeled_image))
366366
```
367367

368-
Note this is the default behaviour for newer versions of `matplotlib.pyplot.imshow`.
368+
Note this is the default behaviour for newer versions of `matplotlib.pyplot.imshow`.
369369
Alternatively we could convert the image to RGB and then display it.
370370

371371

@@ -376,7 +376,7 @@ Alternatively we could convert the image to RGB and then display it.
376376
## Suppressing outputs in Jupyter Notebooks
377377

378378
We just used `ax.set_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)
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)
380380
the axis limits. This is specific to Jupyter Notebooks.
381381

382382
::::::::::::::::::::::::::::::::::::::::::::::::::

episodes/fig/beads.jpg

2.25 MB
Loading

episodes/fig/board.jpg

117 KB
Loading

0 commit comments

Comments
 (0)