1
1
---
2
- title : " Image Representation in skimage"
2
+ title : " Working with skimage"
3
3
teaching : 70
4
4
exercises : 50
5
5
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 ?"
7
7
objectives :
8
- - " Explain how images are stored in NumPy arrays."
9
- - " Explain the order of the three colour values in skimage images."
10
8
- " Read, display, and save images."
11
9
- " Resize images with skimage."
12
10
- " Perform simple image thresholding with NumPy array operations."
13
11
- " Extract sub-images using array slicing."
14
12
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."
18
13
- " Images are read from disk with the `skimage.io.imread()` function."
19
14
- " We create a window that automatically scales the displayed image
20
15
with matplotlib and calling `show()` on the global figure object."
@@ -28,59 +23,8 @@ images, e.g., `clip = image[60:150, 135:480, :]`."
28
23
- " Metadata is not retained when images are loaded as skimage images."
29
24
---
30
25
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}
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.
84
28
85
29
## Reading, displaying, and saving images
86
30
0 commit comments