Skip to content

Commit 8030c1c

Browse files
author
Robert (Bob) Turner
committed
Revert "remove 3 colour image"
This reverts commit b4c5b49.
1 parent 1d70a75 commit 8030c1c

File tree

2 files changed

+60
-9
lines changed

2 files changed

+60
-9
lines changed

episodes/02-image-basics.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ 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."
1110
- "Explain the left-hand coordinate system used in digital images."
1211
- "Explain the RGB additive colour model used in digital images."
13-
- "Explain the order of the three colour values in skimage images."
1412
- "Explain the characteristics of the BMP, JPEG, and TIFF image formats."
1513
- "Explain the difference between lossy and lossless compression."
1614
- "Explain the advantages and disadvantages of compressed image formats."
@@ -22,9 +20,6 @@ upper left corner, the x-axis running to the right, and the y-axis running
2220
down."
2321
- "Most frequently, digital images use an additive RGB model, with eight bits
2422
for the red, green, and blue channels."
25-
- "skimage images are stored as multi-dimensional NumPy arrays."
26-
- "In skimage images, the red channel is specified first, then the green, then
27-
the blue, i.e., RGB."
2823
- "Lossless compression retains all the details in an image, but lossy
2924
compression results in loss of some of the original image detail."
3025
- "BMP images are uncompressed, meaning they have high quality but also that

episodes/03-skimage-images.md

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
---
2-
title: "Working with skimage"
2+
title: "Image Representation in skimage"
33
teaching: 70
44
exercises: 50
55
questions:
6-
- "How can the skimage Python computer vision library be used to work with images?"
6+
- "How are digital images stored in Python with the skimage computer vision library?"
77
objectives:
8+
- "Explain how images are stored in NumPy arrays."
9+
- "Explain the order of the three colour values in skimage images."
810
- "Read, display, and save images."
911
- "Resize images with skimage."
1012
- "Perform simple image thresholding with NumPy array operations."
1113
- "Extract sub-images using array slicing."
1214
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."
1318
- "Images are read from disk with the `skimage.io.imread()` function."
1419
- "We create a window that automatically scales the displayed image
1520
with matplotlib and calling `show()` on the global figure object."
@@ -23,8 +28,59 @@ images, e.g., `clip = image[60:150, 135:480, :]`."
2328
- "Metadata is not retained when images are loaded as skimage images."
2429
---
2530

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.
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 (x, y) 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+
*(y, x)* 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 y coordinate first, then the x.
80+
> Further, the first channel stored is the red channel,
81+
> followed by the green, and then the blue.
82+
>
83+
{: .callout}
2884

2985
## Reading, displaying, and saving images
3086

0 commit comments

Comments
 (0)