-
-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ep3: iio.imread is unreliable #249
Comments
Hi @gcapes, There is a sentence related to this in episode 5 and I realize it should be moved to episode 3 instead, when using "The first argument to iio.imread() is the filename of the image. The second argument mode="L" defines the type and depth of a pixel in the image (e.g., an 8-bit pixel has a range of 0-255). This argument is forwarded to the pillow backend, for which mode “L” means 8-bit pixels and single-channel (i.e., grayscale). pillow is a Python imaging library; which backend is used by iio.imread() may be specified (to use pillow, you would pass this argument: plugin="pillow"); if unspecified, iio.imread() determines the backend to use based on the image type." Do you have |
Which OS are you running? Were you able to follow https://datacarpentry.org/image-processing/setup/? I guess the test at the end will give you a blank image at this point... |
I'm on Linux Mint. I'm not using Anaconda, but have set up a venv with all the required packages as far as I can tell, including scikit-image version 0.19.3 using python 3.10. The test gives me what looks to be success: I've worked round this problem it for the tutorial, so I'm only really reporting it as something which might affect other learners. It only seems to affect that png image. JPG and TIFF are loading ok. Feel free to close if this isn't reproducible. Thanks! |
Strange... I cannot reproduce it on my end, indeed (the PNG image is displaying fine for me); I'm running Python 3.9.15 on Debian GNU/Linux 11 (bullseye). |
I can reproduce this. (Aside: there is also a small error in the solution block, where we have forgotten to import imageio as The immediate issue is coming from the way that The rest of the solution assumes that the @gcapes here is a solution that should work for the exercise: import imageio.v3 as iio
import matplotlib.pyplot as plt
image = iio.imread(uri="data/sudoku.png", mode="L")
image[image > 190] = 190
plt.imshow(image, cmap='gray', vmin=0, vmax=255) Moving onto the question of how to fix this, it is made quite complicated by the fact that the sudoku image has an alpha channel. So import skimage.color
image = iio.imread(uri="data/sudoku.png")
gray_image = skimage.color.rgb2gray(image)
I can propose four options from here:
Here are my thoughts on each of these:
Thoughts very welcome from anyone with more working experience of image processing @mkcor @bobturneruk @K-Meech @quist00 @uschille |
Well done @tobyhodges for getting to the bottom of this! |
Oh, sorry, I had skipped the I agree that using a conversion function such as |
I wasn't able to load the sudoku image properly using
iio.imread
but it worked ok using matplotlib.I wonder if anyone else has had any trouble? Images up to this point in the lesson have loaded ok.
The text was updated successfully, but these errors were encountered: