@@ -8,11 +8,11 @@ exercises: 5
8
8
9
9
- Define the terms bit, byte, kilobyte, megabyte, etc.
10
10
- Explain how a digital image is composed of pixels.
11
- - Recommend using imageio (resp. skimage ) for I/O (resp. image processing) tasks.
11
+ - Recommend using imageio (resp. scikit-image ) for I/O (resp. image processing) tasks.
12
12
- Explain how images are stored in NumPy arrays.
13
13
- Explain the left-hand coordinate system used in digital images.
14
14
- Explain the RGB additive colour model used in digital images.
15
- - Explain the order of the three colour values in skimage images.
15
+ - Explain the order of the three colour values in scikit-image images.
16
16
- Explain the characteristics of the BMP, JPEG, and TIFF image formats.
17
17
- Explain the difference between lossy and lossless compression.
18
18
- Explain the advantages and disadvantages of compressed image formats.
@@ -72,7 +72,7 @@ The **matrix** is mathematical concept - numbers evenly arranged in a rectangle.
72
72
like the shape of the screen you're looking at now. Or it could be a three dimensional equivalent, a cuboid, or have
73
73
even more dimensions, but always keeping the evenly spaced arrangement of numbers. In computing, ** array** refers
74
74
to a structure in the computer's memory where data is stored in evenly-spaced ** elements** . This is strongly analogous
75
- to a matrix. A ` numpy ` array is a ** type** of variable (a simpler example of a type is an integer). For our purposes,
75
+ to a matrix. A NumPy array is a ** type** of variable (a simpler example of a type is an integer). For our purposes,
76
76
the distinction between matrices and arrays is not important, we don't really care how the computer arranges our data
77
77
in its memory. The important thing is that the computer stores values describing the pixels in images, as arrays. And
78
78
the terms matrix and array can be used interchangeably.
@@ -111,7 +111,7 @@ Additional functionality can be loaded as a single function or object,
111
111
a module defining several of these, or a library containing many modules.
112
112
You will encounter several different forms of ` import ` statement.
113
113
114
- ``` python
114
+ ``` python
115
115
import skimage # form 1, load whole skimage library
116
116
import skimage.draw # form 2, load skimage.draw module only
117
117
from skimage.draw import disk # form 3, load only the disk function
@@ -122,7 +122,7 @@ import numpy as np # form 4, load all of numpy into an object called
122
122
123
123
## Further Explanation
124
124
125
- In the example above, form 1 loads the entire ` skimage ` library into the
125
+ In the example above, form 1 loads the entire scikit-image library into the
126
126
program as an object.
127
127
Individual modules of the library are then available within that object,
128
128
e.g., to access the ` disk ` function used in [ the drawing episode] ( 04-drawing.md ) ,
@@ -131,7 +131,7 @@ you would write `skimage.draw.disk()`.
131
131
Form 2 loads only the ` draw ` module of ` skimage ` into the program.
132
132
When we run the code,
133
133
the program will take less time and use less memory
134
- because we will not load the whole ` skimage ` library.
134
+ because we will not load the whole scikit-image library.
135
135
The syntax needed to use the module remains unchanged:
136
136
to access the ` disk ` function,
137
137
we would use the same function call as given for form 1.
@@ -182,7 +182,7 @@ natively (think of volumes, movies).
182
182
183
183
## Why not use ` skimage.io.imread() `
184
184
185
- The ` skimage ` library has its own function to read an image,
185
+ The scikit-image library has its own function to read an image,
186
186
so you might be asking why we don't use it here.
187
187
Actually, ` skimage.io.imread() ` uses ` iio.imread() ` internally when loading an image into Python.
188
188
It is certainly something you may use as you see fit in your own code.
@@ -226,7 +226,7 @@ print(eight.shape)
226
226
print (eight)
227
227
```
228
228
229
- ``` output
229
+ ``` output
230
230
(5, 3)
231
231
[[0. 0. 0.]
232
232
[0. 1. 0.]
@@ -237,8 +237,8 @@ print(eight)
237
237
238
238
Thus if we have tools that will allow us to manipulate these arrays of numbers,
239
239
we can manipulate the image.
240
- The ` numpy ` library can be particularly useful here,
241
- so let's try that out using ` numpy ` array slicing.
240
+ The NumPy library can be particularly useful here,
241
+ so let's try that out using NumPy array slicing.
242
242
Notice that the default behavior of the ` imshow ` function appended row and
243
243
column numbers that will be helpful to us as we try to address individual or
244
244
groups of pixels.
@@ -262,7 +262,7 @@ plt.imshow(zero)
262
262
print (zero)
263
263
```
264
264
265
- ``` output
265
+ ``` output
266
266
[[0. 0. 0.]
267
267
[0. 1. 0.]
268
268
[0. 1. 0.]
@@ -337,7 +337,7 @@ plt.imshow(five)
337
337
print (five)
338
338
```
339
339
340
- ``` output
340
+ ``` output
341
341
[[0. 0. 0.]
342
342
[0. 1. 1.]
343
343
[0. 0. 0.]
@@ -433,7 +433,7 @@ key to certain techniques explored in later chapters of this lesson.
433
433
To get started let's see an example of how different dimensions of information
434
434
combine to produce a set of pixels using a 4 X 4 matrix with 3 dimensions
435
435
for the colours red, green, and blue.
436
- Rather than loading it from a file, we will generate this example using numpy .
436
+ Rather than loading it from a file, we will generate this example using NumPy .
437
437
438
438
``` python
439
439
# set the random seed so we all get the same matrix
@@ -447,7 +447,7 @@ plt.imshow(checkerboard)
447
447
print (checkerboard)
448
448
```
449
449
450
- ``` output
450
+ ``` output
451
451
[[[116 85 57]
452
452
[128 109 94]
453
453
[214 44 62]
@@ -658,11 +658,11 @@ There are several image formats we might encounter,
658
658
and we should know the basics of at least of few of them.
659
659
Some formats we might encounter, and their file extensions, are shown in this table:
660
660
661
- | Format | Extension |
661
+ | Format | Extension |
662
662
| :-------------------------------------- | :------------ |
663
- | Device-Independent Bitmap (BMP) | .bmp |
664
- | Joint Photographic Experts Group (JPEG) | .jpg or .jpeg |
665
- | Tagged Image File Format (TIFF) | .tif or .tiff |
663
+ | Device-Independent Bitmap (BMP) | .bmp |
664
+ | Joint Photographic Experts Group (JPEG) | .jpg or .jpeg |
665
+ | Tagged Image File Format (TIFF) | .tif or .tiff |
666
666
667
667
## BMP
668
668
@@ -742,12 +742,12 @@ The amount of memory (RAM) and drive space our computers have is quantified
742
742
by terms like Megabytes (MB), Gigabytes (GB), and Terabytes (TB).
743
743
The following table provides more formal definitions for these terms.
744
744
745
- | Unit | Abbreviation | Size |
745
+ | Unit | Abbreviation | Size |
746
746
| :-------------------------------------- | ------------- | :--------- |
747
- | Kilobyte | KB | 1024 bytes |
748
- | Megabyte | MB | 1024 KB |
749
- | Gigabyte | GB | 1024 MB |
750
- | Terabyte | TB | 1024 GB |
747
+ | Kilobyte | KB | 1024 bytes |
748
+ | Megabyte | MB | 1024 KB |
749
+ | Gigabyte | GB | 1024 MB |
750
+ | Terabyte | TB | 1024 GB |
751
751
752
752
::::::::::::::::::::::::::::::::::::::::::::::::::
753
753
@@ -1025,7 +1025,7 @@ metadata = iio.immeta(uri="data/eight.tif")
1025
1025
metadata
1026
1026
```
1027
1027
1028
- ``` output
1028
+ ``` output
1029
1029
{'is_fluoview': False,
1030
1030
'is_nih': False,
1031
1031
'is_micromanager': False,
@@ -1060,29 +1060,27 @@ the metadata of your images.
1060
1060
The following table summarises the characteristics of the BMP, JPEG, and TIFF
1061
1061
image formats:
1062
1062
1063
- | Format | Compression | Metadata | Advantages | Disadvantages |
1063
+ | Format | Compression | Metadata | Advantages | Disadvantages |
1064
1064
| :-------------------------------------- | :------------ | :--------- | :--------------------- | :----------------------------------------- |
1065
- | BMP | None | None | Universally viewable, | Large file sizes |
1066
- | | | | high quality | |
1067
- | JPEG | Lossy | Yes | Universally viewable, | Detail may be lost |
1068
- | | | | smaller file size | |
1069
- | PNG | Lossless | [ Yes] ( https://www.w3.org/TR/PNG/#11keywords ) | Universally viewable, [ open standard] ( https://www.w3.org/TR/PNG/ ) , smaller file size | Metadata less flexible than TIFF, RGB only |
1070
- | TIFF | None, lossy, | Yes | High quality or | Not universally viewable |
1071
- | | or lossless | | smaller file size | |
1065
+ | BMP | None | None | Universally viewable, | Large file sizes |
1066
+ | | | | high quality | |
1067
+ | JPEG | Lossy | Yes | Universally viewable, | Detail may be lost |
1068
+ | | | | smaller file size | |
1069
+ | PNG | Lossless | [ Yes] ( https://www.w3.org/TR/PNG/#11keywords ) | Universally viewable, [ open standard] ( https://www.w3.org/TR/PNG/ ) , smaller file size | Metadata less flexible than TIFF, RGB only |
1070
+ | TIFF | None, lossy, | Yes | High quality or | Not universally viewable |
1071
+ | | or lossless | | smaller file size | |
1072
1072
1073
1073
:::::::::::::::::::::::::::::::::::::::: keypoints
1074
1074
1075
1075
- Digital images are represented as rectangular arrays of square pixels.
1076
1076
- Digital images use a left-hand coordinate system, with the origin in the upper left corner, the x-axis running to the right, and the y-axis running down. Some learners may prefer to think in terms of counting down rows for the y-axis and across columns for the x-axis. Thus, we will make an effort to allow for both approaches in our lesson presentation.
1077
1077
- Most frequently, digital images use an additive RGB model, with eight bits for the red, green, and blue channels.
1078
- - skimage images are stored as multi-dimensional NumPy arrays.
1079
- - In skimage images, the red channel is specified first, then the green, then the blue, i.e., RGB.
1078
+ - scikit-image images are stored as multi-dimensional NumPy arrays.
1079
+ - In scikit-image images, the red channel is specified first, then the green, then the blue, i.e., RGB.
1080
1080
- Lossless compression retains all the details in an image, but lossy compression results in loss of some of the original image detail.
1081
1081
- BMP images are uncompressed, meaning they have high quality but also that their file sizes are large.
1082
1082
- JPEG images use lossy compression, meaning that their file sizes are smaller, but image quality may suffer.
1083
1083
- TIFF images can be uncompressed or compressed with lossy or lossless compression.
1084
1084
- Depending on the camera or sensor, various useful pieces of information may be stored in an image file, in the image metadata.
1085
1085
1086
1086
::::::::::::::::::::::::::::::::::::::::::::::::::
1087
-
1088
-
0 commit comments