From e2588e90233f8191f4fdfd5aa763797f33cf2361 Mon Sep 17 00:00:00 2001 From: Toby Hodges Date: Mon, 18 Sep 2023 10:57:29 +0200 Subject: [PATCH 1/2] imageio library name formatting --- episodes/02-image-basics.md | 8 ++++---- episodes/03-skimage-images.md | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/episodes/02-image-basics.md b/episodes/02-image-basics.md index 89a1d0ba8..fc45f274b 100644 --- a/episodes/02-image-basics.md +++ b/episodes/02-image-basics.md @@ -166,8 +166,8 @@ With that taken care of, let's load our image data from disk using the `imread` function from the `imageio.v3` module and display it using the `imshow` function from the `matplotlib.pyplot` module. -`imageio` is a Python library for reading and writing image data. -`imageio.v3` is specifying that we want to use version 3 of `imageio`. This +Imageio is a Python library for reading and writing image data. +`imageio.v3` is specifying that we want to use version 3 of imageio. This version has the benefit of supporting nD (multidimensional) image data natively (think of volumes, movies). @@ -179,9 +179,9 @@ The scikit-image library has its own function to read an image, so you might be asking why we don't use it here. Actually, `skimage.io.imread()` uses `iio.imread()` internally when loading an image into Python. It is certainly something you may use as you see fit in your own code. -In this lesson, we use the `imageio` library to read or write (save) images, +In this lesson, we use the imageio library to read or write (save) images, while `skimage` is dedicated to performing operations on the images. -Using `imageio` gives us more flexibility, especially when it comes to +Using imageio gives us more flexibility, especially when it comes to handling metadata. :::::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/episodes/03-skimage-images.md b/episodes/03-skimage-images.md index 043061acc..8b48c3665 100644 --- a/episodes/03-skimage-images.md +++ b/episodes/03-skimage-images.md @@ -256,9 +256,9 @@ We will start by reading the image and displaying it. ::::::::::::::::::::::::::::::::::::::::: callout -## Loading images with `imageio`: Read-only arrays +## Loading images with imageio: Read-only arrays -When loading an image with `imageio`, in certain situations the image is stored in a read-only array. If you attempt to manipulate the pixels in a read-only array, you will receive an error message `ValueError: assignment destination is read-only`. In order to make the image array writeable, we can create a copy with `image = np.array(image)` before manipulating the pixel values. +When loading an image with imageio, in certain situations the image is stored in a read-only array. If you attempt to manipulate the pixels in a read-only array, you will receive an error message `ValueError: assignment destination is read-only`. In order to make the image array writeable, we can create a copy with `image = np.array(image)` before manipulating the pixel values. :::::::::::::::::::::::::::::::::::::::::::::::::: @@ -359,7 +359,7 @@ pass `plugin="pillow"`. If the backend is not specified explicitly, `iio.imread( ::::::::::::::::::::::::::::::::::::::::: callout -## Loading images with `imageio`: Pixel type and depth +## Loading images with imageio: Pixel type and depth When loading an image with `mode="L"`, the pixel values are stored as 8-bit integer numbers that can take values in the range 0-255. However, pixel values may also be stored with other types and ranges. For example, some scikit-image functions return the pixel values as floating point numbers in the range 0-1. The type and range of the pixel values are important for the colorscale when plotting, and for masking and thresholding images as we will see later in the lesson. If you are unsure about the type of the pixel values, you can inspect it with `print(image.dtype)`. For the example above, you should find that it is `dtype('uint8')` indicating 8-bit integer numbers. @@ -393,7 +393,7 @@ range 0-255 of an 8-bit pixel). The results should look like this: ## Solution -First, load the image file `data/sudoku.png` as a grayscale image. Remember that we use `image = np.array(image)` to create a copy of the image array because `imageio` returns a non-writeable image. +First, load the image file `data/sudoku.png` as a grayscale image. Remember that we use `image = np.array(image)` to create a copy of the image array because `imageio.imread` returns a non-writeable image. ```python From 17ec6d4f0b910dbf0a67f85281fdff487a5d9f11 Mon Sep 17 00:00:00 2001 From: Toby Hodges Date: Mon, 18 Sep 2023 10:58:26 +0200 Subject: [PATCH 2/2] fix a skimage->scikit-image that was missed earlier --- episodes/02-image-basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/episodes/02-image-basics.md b/episodes/02-image-basics.md index fc45f274b..61d52c3dd 100644 --- a/episodes/02-image-basics.md +++ b/episodes/02-image-basics.md @@ -180,7 +180,7 @@ so you might be asking why we don't use it here. Actually, `skimage.io.imread()` uses `iio.imread()` internally when loading an image into Python. It is certainly something you may use as you see fit in your own code. In this lesson, we use the imageio library to read or write (save) images, -while `skimage` is dedicated to performing operations on the images. +while scikit-image is dedicated to performing operations on the images. Using imageio gives us more flexibility, especially when it comes to handling metadata.