Skip to content

Selecting and plotting color channels #370

Open

Description

@sstevens2

How could the content be improved?

Our instructor selected the color channels out instead of multiplying the others by 0 when he plotted the red, green, and blue channels separately. From what I could tell, the way the lesson is written with multiplying the other channels by 0 it inverts the colors when plotting, where the light red is dark red and vise versa and the selection method doesn't do that. Maybe should switch to selecting the channel instead of multiplying by 0's?

Which part of the content does your suggestion apply to?

https://datacarpentry.github.io/image-processing/02-image-basics.html

Activity

  1. marcodallavecchia commented on Aug 27, 2026

    @marcodallavecchia
    Contributor

    Thanks a lot @sstevens2! We have discussed today this issues and we agreed that selecting the channels with the list multiplication is a little unexpected.

    The reason behind it is that it keeps the red_channel / green_channel / blue_channel arrays as RGB arrays (with shape (4,4,3)) which will default to the expected RGB rendering when displayed with Matplotlib. In this case low values are close to black and high values go towards the bright red/green/blue.

    Selecting a single channel and keeping it as a 2D array, it would render it automatically with the viridis cmap. Unfortunately matplotlib default colormaps don't have a traditional black-to-red / black-to-green / black-to-blue colormaps which can be used to emulate the RGB array display behaviour.

    I will propose a few solutions for this better clarify this section in the coming weeks. We are possibly thinking of having an additional callout block to suggest the alternatives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions