Closed gcapes closed 2 years ago
Thanks for reporting this and the other issues, @gcapes - you are finding wrinkles that it is very helpful to iron out!
That said, I'm afraid I have not been able to reproduce this one.
Could you share the whole code block and output please, so we can try to figure out what is going on here?
MWE:
import numpy as np
import matplotlib.pyplot as plt
import ipympl
import imageio.v3 as iio
import skimage
%matplotlib widget
"""
* Python script to ignore low intensity pixels in an image.
*
"""
import imageio.v3 as iio
# read input image
image = iio.imread(uri="data/maize-root-cluster.jpg")
# display original image
fig, ax = plt.subplots()
plt.imshow(image)
# keep only high-intensity pixels
image[image < 128] = 0
# display modified image
fig, ax = plt.subplots()
plt.imshow(image)
Hmmm. Can confirm this works with no errors on my end. I will go looking for an explanation of why this might be happening to you elsewhere on the Internet...
Ok, I believe this issue thread provides an explanation for the behaviour you're observing: https://github.com/imageio/imageio/issues/877
I need to spend some time reading through it, and then I think it will need to be raised with the rest of the Maintainer team, and potentially the Curriculum Advisors, to figure out how we will handle this consistently throughout the lesson.
I can reproduce this. Will dig into it while addressing #252.
Based on the discussions in https://github.com/imageio/imageio/issues/877 and https://github.com/python-pillow/Pillow/issues/6581, image = np.array(image)
may be a quick fix. A downside of this is the added cognitive load of thinking about writeable/non-writeable images. Maybe this is unavoidable in view of how the imageio
backend works.
@mkcor Do you have any better suggestions?
In this section https://datacarpentry.org/image-processing/03-skimage-images/index.html#manipulating-pixels we're keeping only high-intensity pixels. However, I get the following error:
Making a copy of the image first fixes the problem.
image_copy = image.copy()