Skip to content

Input of threshold_otsu should be grayscale, but this is not documented #1867

Closed

Description

@emmanuelle

If an RGB image is passed to threshold_otsu, all color channels are mixed because ravel is caused. The resulting threshold does not make much sense usually. A user reported a problem that was due to this behaviour on the mailing-list https://groups.google.com/forum/#!topic/scikit-image/QP6sHolCVgs

I see two solutions:

  • add in the docstring that the image should be grayscale, and raise a warning if the shape of the image is (n_row, n_col, 3 or 4).
  • add a multichannel keyword argument and compute a threshold value for each channel (using adapt_rgb decorator??). However, I'm not sure whether it's of any use to return a vector threshold instead of a scalar value.

Long-term solution: look for a multichannel thresholding algorithm, that would typically use clustering I think.

Activity

  1. anuragphadke commented on Jan 8, 2016

    @anuragphadke

    following up on the issue, converting the image to grayscale and saving as JPG via GIMP also works.

  2. JDWarner commented on Jan 9, 2016

    @JDWarner
    Contributor

    Caution: JPEG is lossy and usually RGB under the hood. It's very common for a grayscale image saved as JPEG to have minor color halos.

    Instead, save as PNG - which is lossless - or consider using rgb2gray in this package.

  3. OrkoHunter commented on Jan 24, 2016

    @OrkoHunter
    Contributor

    Should this be closed now?

  4. JDWarner commented on Jan 24, 2016

    @JDWarner
    Contributor

    Closed by #1876, thanks for the reminder @OrkoHunter

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions