Skip to content

Commit cafb0fa

Browse files
committed
Merge branch 'gh-pages' into pr/useRYandCX
2 parents e8ed9a0 + 7647156 commit cafb0fa

File tree

6 files changed

+36
-75
lines changed

6 files changed

+36
-75
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
A lesson teaching foundational image processing skills with Python and [scikit-image](https://scikit-image.org/).
77

8-
**The lesson is currently under active development and should not be considered stable.** We are aiming for a beta release to the Data Carpentry community before the end of 2021.
8+
**The lesson is currently under active development and should not be considered stable. We are looking or volunteers to host and teach beta pilot workshops now.**
99

1010
## Lesson Content
1111

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ title: "Image Processing with Python"
1414

1515
# Life cycle stage of the lesson
1616
# possible values: "pre-alpha", "alpha", "beta", "stable"
17-
life_cycle: "alpha"
17+
life_cycle: "beta"
1818

1919
#------------------------------------------------------------
2020
# Generic settings (should not need to change).

_episodes/02-image-basics.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ questions:
77
objectives:
88
- "Define the terms bit, byte, kilobyte, megabyte, etc."
99
- "Explain how a digital image is composed of pixels."
10+
- "Explain how images are stored in NumPy arrays."
1011
- "Explain the left-hand coordinate system used in digital images."
1112
- "Explain the RGB additive colour model used in digital images."
13+
- "Explain the order of the three colour values in skimage images."
1214
- "Explain the characteristics of the BMP, JPEG, and TIFF image formats."
1315
- "Explain the difference between lossy and lossless compression."
1416
- "Explain the advantages and disadvantages of compressed image formats."
@@ -22,6 +24,9 @@ for the y-axis and across columns for the x-axis. Thus, we will make an
2224
effort to allow for both approaches in our lesson presentation."
2325
- "Most frequently, digital images use an additive RGB model, with eight bits
2426
for the red, green, and blue channels."
27+
- "skimage images are stored as multi-dimensional NumPy arrays."
28+
- "In skimage images, the red channel is specified first, then the green, then
29+
the blue, i.e., RGB."
2530
- "Lossless compression retains all the details in an image, but lossy
2631
compression results in loss of some of the original image detail."
2732
- "BMP images are uncompressed, meaning they have high quality but also that
@@ -69,8 +74,20 @@ real world images will typically be made up of a vast number of pixels,
6974
and each of these pixels will be one of potentially millions of colours.
7075
While we will deal with pictures of such complexity shortly,
7176
let's start our exploration with 15 pixels in a 5 X 3 matrix with 2 colours and
72-
work our way up to that complexity,
73-
but first the necessary imports.
77+
work our way up to that complexity.
78+
79+
> ## Matrices, arrays, images and pixels
80+
> The **matrix** is mathematical concept - numbers evenly arranged in a rectangle. This can be a two dimensional rectangle,
81+
> like the shape of the screen you're looking at now. Or it could be a three dimensional equivalent, a cuboid, or have
82+
> even more dimensions, but always keeping the evenly spaced arrangement of numbers. In computing, **array** refers
83+
> to a structure in the computer's memory where data is stored in evenly-spaced **elements**. This is strongly analogous
84+
> to a matrix. A `numpy` array is a **type** of variable (a simpler example of a type is an integer). For our purposes,
85+
> the distinction between matrices and arrays is not important, we don't really care how the computer arranges our data
86+
> in its memory. The important thing is that the computer stores values describing the pixels in images, as arrays. And
87+
> the terms matrix and array can be used intechangably.
88+
{: .callout}
89+
90+
First, the necessary imports:
7491

7592
~~~
7693
"""

_episodes/03-skimage-images.md

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
---
2-
title: "Image Representation in skimage"
2+
title: "Working with skimage"
33
teaching: 70
44
exercises: 50
55
questions:
6-
- "How are digital images stored in Python with the skimage computer vision library?"
6+
- "How can the skimage Python computer vision library be used to work with images?"
77
objectives:
8-
- "Explain how images are stored in NumPy arrays."
9-
- "Explain the order of the three colour values in skimage images."
108
- "Read, display, and save images."
119
- "Resize images with skimage."
1210
- "Perform simple image thresholding with NumPy array operations."
1311
- "Extract sub-images using array slicing."
1412
keypoints:
15-
- "skimage images are stored as multi-dimensional NumPy arrays."
16-
- "In skimage images, the red channel is specified first, then the green, then
17-
the blue, i.e., RGB."
1813
- "Images are read from disk with the `skimage.io.imread()` function."
1914
- "We create a window that automatically scales the displayed image
2015
with matplotlib and calling `show()` on the global figure object."
@@ -28,59 +23,8 @@ images, e.g., `clip = image[60:150, 135:480, :]`."
2823
- "Metadata is not retained when images are loaded as skimage images."
2924
---
3025

31-
Now that we know a bit about computer images in general,
32-
let us review and expand on the concepts we just learned.
33-
34-
## Images are represented as NumPy arrays
35-
36-
In [the Image Basics episode]({{page.root}}{% link _episodes/02-image-basics.md %}),
37-
we learned that images are represented as
38-
rectangular arrays of individually-coloured square pixels,
39-
and that the colour of each pixel can be represented as an RGB triplet of numbers.
40-
On import, skimage stores the information for each pixel in an n-dimensional NumPy arrays.
41-
42-
The rectangular shape of the array corresponds to the shape of the image,
43-
although the order of the coordinates are reversed.
44-
The "depth" of the array for a full-colour image in skimage image is three,
45-
with one layer for each of the three channels.
46-
The differences in the order of coordinates and the order of the channel
47-
layers can cause some confusion,
48-
so we should spend a bit more time looking at that.
49-
50-
When we think of a pixel in an image,
51-
we think of its (cx, ry) coordinates (in a left-hand coordinate system)
52-
like (113, 45) and its colour,
53-
specified as a RGB triple like (245, 134, 29).
54-
In an skimage image, the same pixel would be specified with
55-
*(ry, cx)* coordinates (45, 113) and *RGB* colour (245, 134, 29).
56-
57-
Let us take a look at this idea visually.
58-
Consider this image of a chair:
59-
60-
![Chair image](../fig/chair-original.jpg)
61-
62-
A visual representation of how this image is stored as a NumPy array is:
63-
64-
![Chair layers](../fig/chair-layers-rgb.png)
65-
66-
So, when we are working with skimage images,
67-
we specify the *y* coordinate first,
68-
then the *x* coordinate.
69-
And, the colours are stored as *RGB* values -
70-
red in layer 0,
71-
green in layer 1,
72-
blue in layer 2.
73-
74-
> ## Coordinate and colour channel order
75-
>
76-
> CAUTION: it is vital to remember the order of the coordinates and
77-
> colour channels when dealing with images as NumPy arrays.
78-
> *If* we are manipulating or accessing an image array directly,
79-
> we specifiy the ry coordinate first, then the cx.
80-
> Further, the first channel stored is the red channel,
81-
> followed by the green, and then the blue.
82-
>
83-
{: .callout}
26+
We have covered much of how images are represented in computer software. In this episode we will learn some more methods
27+
for accessing and changing digital images.
8428

8529
## Reading, displaying, and saving images
8630

_extras/about.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
---
22
title: About
33
---
4+
5+
This lesson was initially created for use in the
6+
[Digital Imaging and Vision Applications in Science (DIVAS)](http://www.doane.edu/divas-project)
7+
Image Processing summer workshop.
8+
49
{% include carpentries.html %}
510
{% include links.md %}

index.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@ layout: lesson
33
root: .
44
---
55

6-
*Note: This site is not an official Data Carpentry lesson. The lesson
7-
is under development for use in the
8-
[Digital Imaging and Vision Applications in Science (DIVAS)](http://www.doane.edu/divas-project)
9-
Image Processing summer workshop and is in the process of becoming an official Data Carpentry lesson.*
10-
116
This lesson shows how to use Python and skimage to do basic image processing.
127

138
> ## Prerequisites
14-
>
15-
> This lesson assumes you have a working knowledge of Python and some previous exposure to the Bash shell.
16-
> These requirements can be fulfilled by:
17-
> a) completing a Software Carpentry Python workshop **or**
18-
> b) completing a Data Carpentry Ecology workshop (with Python) **and** a Data Carpentry Genomics workshop **or**
19-
> c) independent exposure to both Python and the Bash shell.
9+
>
10+
> This lesson assumes you have a working knowledge of Python and some previous exposure to the Bash shell.
11+
> These requirements can be fulfilled by:
12+
> a) completing a Software Carpentry Python workshop **or**
13+
> b) completing a Data Carpentry Ecology workshop (with Python) **and** a Data Carpentry Genomics workshop **or**
14+
> c) independent exposure to both Python and the Bash shell.
2015
>
2116
> If you're unsure whether you have enough experience to participate in this workshop, please read over
2217
> [this detailed list]({{ page.root }}{% link _extras/prereqs.md %}), which gives all of the functions, operators, and other concepts you will need

0 commit comments

Comments
 (0)