Comments (9)
It's all good, @uschille! I find it's a good thing that we have moved away from using argument as_gray=True
with skimage.io.imread()
, because it would change the dtype of this image implicitly (from uint8 to float64); without as_gray=True
, skimage.io.imread()
, would read it as uint8; imageio.v3.imread()
reads it as uint8 regardless of RGB or grayscale.
from image-processing.
I'll find the issue some other time
cf. scikit-image/scikit-image#1234
No worries, thanks for the clarification @mkcor. I guess I was misinterpreting
https://pillow.readthedocs.io/en/stable/handbook/concepts.html#concept-modes.
I see!
from image-processing.
Thanks @mkcor. Just to make sure I understand correctly, you would favor uint8
as the default dtype
for both RGB and grayscale images? I believe there are other episodes that use the range 0-1 for grayscale values, so those would need to be updated as well.
I also realized that there is potential confusion when using skimage.color.rgb2gray()
which will implicitly convert the dtype
to float64
, so I'll check that skimage.util.img_as_ubyte()
(as explained in Ep. 3) is used consistently throughout the lesson.
P.S.: I've thought about mode='F'
but the pillow backend seems to only support float32
(not float64
), which imho does not really help to avoid confusion.
from image-processing.
I think there is actually a more general question on how to handle grayscale images (uint8 vs. float64 and their ranges).
In episode 03-skimage-images, for example, we mention skimage.util.img_as_ubyte()
. On the other hand, elsewhere in the same episode we say
Note that it is often better to use image values represented by floating point values, because using floating point numbers is numerically more stable.
Then in episode 05-creating-histograms, we use image = skimage.util.img_as_float(image)
.
To avoid confusion and reduce cognitive load, I would be in favor of streamlining and handling grayscale images consistently throughout the lesson - will open a separate issue for feedback and discussion.
from image-processing.
Pending discussion in #256.
from image-processing.
Hi @uschille,
Thanks @mkcor. Just to make sure I understand correctly, you would favor
uint8
as the defaultdtype
for both RGB and grayscale images?
No: It depends on the actual image at hand. My approach is very much practical and 'real-world' (images come as they are, some formats are more common in certain fields, etc.). So I think we should read images as they present themselves. And we should convert them only if we need to, e.g., if we want to apply specific transformations to them.
I believe there are other episodes that use the range 0-1 for grayscale values, so those would need to be updated as well.
That's not how I see it. If other episodes use other images, which have other dtypes, so be it. As you mentioned elsewhere, it illustrates the real world, where images come in different formats. From an educational perspective, what we want to convey is that it's important to be aware of the dtype of our images. Do we want to enhance the lesson with a line checking for the dtype each time an image is being loaded?
I also realized that there is potential confusion when using
skimage.color.rgb2gray()
which will implicitly convert thedtype
tofloat64
, so I'll check thatskimage.util.img_as_ubyte()
(as explained in Ep. 3) is used consistently throughout the lesson.
Ok.
P.S.: I've thought about
mode='F'
but the pillow backend seems to only supportfloat32
(notfloat64
), which imho does not really help to avoid confusion.
Interesting. For the purpose of this lesson, I would rather not distinguish between float32
and float64
. Note that most functions in scikit-image are transparent to the various float dtypes.
from image-processing.
No: It depends on the actual image at hand. My approach is very much practical and 'real-world' (images come as they are, some formats are more common in certain fields, etc.). So I think we should read images as they present themselves. And we should convert them only if we need to, e.g., if we want to apply specific transformations to them.
I'm slightly confused. I thought the dtype
is determined by the argument mode='...'
, so it can be chosen upon loading the image and may involve a conversion (in the case of the sudoku.png from 3x8-bit pixels to 1x8-bit pixels). I think that's useful in this case. In general I agree with you that we should only convert if needed.
From an educational perspective, what we want to convey is that it's important to be aware of the dtype of our images. Do we want to enhance the lesson with a line checking for the dtype each time an image is being loaded?
Yes, this is what I was trying to get to, how do we convey when to pass mode='...'
and what mode to chose (and what to expect when no mode is chosen). I'm a bit wary of introducing too many technical details in the introductory lesson, but a short explanation/callout on dtype
is a good idea 👍 We could add a short explanation at the point where a grayscale image is first loaded as float64
.
from image-processing.
Sorry @uschille, I should be more precise in my wording: I should use 'conversion' only to mean colorspace conversion (which "RGB to grayscale" would fall under) vs. rescaling when changing the range of values (e.g., 0-255 to 0-1). This is something we have discussed at scikit-image (I'll find the issue some other time).
I thought the dtype is determined by the argument
mode='...'
Not really, since adding this argument doesn't change the dtype. It was skimage.io
's grayscale=True
which did.
from image-processing.
No worries, thanks for the clarification @mkcor. I guess I was misinterpreting https://pillow.readthedocs.io/en/stable/handbook/concepts.html#concept-modes.
from image-processing.
Related Issues (20)
- Ep3: Wrong file name `data/sudoku.jpg` HOT 5
- Ep3: iio.imread is unreliable HOT 8
- Release new version of image dataset on FigShare HOT 2
- Use `uint8` or `float64` for grayscale images? HOT 1
- Using image as a variable name HOT 7
- Carpentries Workbench Transition HOT 22
- Showcase image processing at AUNZ community call HOT 7
- Links need to be fixed in CONTRIBUTING.md
- latest version of lesson using "import imageio.v3 as iio" causes error HOT 4
- 'code' folder should be re-established/replaced HOT 5
- Code snippet docstring formatting HOT 4
- Transition to new import convention for sckit-image? HOT 4
- Contributing guide should be customised further
- Ep 5 - Using a Mask for a Histogram exercise error in solution HOT 3
- Link to image publication & analysis checklists HOT 2
- Mask in episode 4 has no shadow HOT 1
- Matplotlib is currently used in a hybrid way (explicit vs. implicit interfaces) HOT 4
- Add Exiftool in list of software that can help handle metadata
- Add "monitoring wading birds in the Everglades using drones" to the list of examples
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from image-processing.