Skip to content

skimage.feature.hog only accepts greyscale images #1879

Closed

Description

@siddarth-jay

According to the docs:

The second stage computes first order image gradients. These capture contour, silhouette and some texture information, while providing further resistance to illumination variations. The locally dominant colour channel is used, which provides colour invariance to a large extent. Variant methods may also include second order image derivatives, which act as primitive bar detectors - a useful feature for capturing, e.g. bar like structures in bicycles and limbs in humans.

But the current implementation only allows greyscale images. Either colour images should be allowed or the documentation needs to reflect this

Activity

  1. ivoflipse commented on Jan 21, 2016

    @ivoflipse
    Contributor

    I reckon it would be good to document this and possibly have the function check if you're giving it something that's more than 2D.

    If you wanted to apply this to color images, I assume you'd have to apply HOG to each color channel separately for it to work?

  2. added
    ⏩ type: Enhancement
    on Jan 21, 2016
  3. siddarth-jay commented on Jan 21, 2016

    @siddarth-jay
    Author

    I reckon it would be good to document this and possibly have the function check if you're giving it something that's more than 2D.

    The documentation indicates that RGB is accepted, but the function does throw a "ValueError: The parameter image must be a 2-dimensional array". As long as the messaging is consistent, either is fine. Although I would prefer that it allow RGB images :)

    And I think you're right as to how to implement it. I'm not sure how they are combined. Max() maybe?

  4. JDWarner commented on Jan 21, 2016

    @JDWarner
    Contributor

    @siddarth-jay if we were to magically combine channels, the best method to do that would be using the luminance channel available via skimage.rgb2gray. But this is not the only way to map RGB data to a grayscale image, so imposing it magically is a little bit dangerous. However, I'd be OK with that design, as it remains possible for users who desire more control to simply apply their own mapping first, then pass the grayscale result to hog.

  5. siddarth-jay commented on Jan 22, 2016

    @siddarth-jay
    Author

    That's how I use it currently. But I think the right way of using it would be to compute it on all three channels and combine them post that. Dalal-Triggs in the original HoG paper, found that performance decreased a little after converting to greyscale and then computing gradients.

  6. sdsingh commented on Feb 25, 2016

    @sdsingh

    I agree with @siddarth-jay: the original paper computes gradients on each channel, and takes the max over each channel's gradient to recombine.

  7. stefanv commented on Feb 25, 2016

    @stefanv
    Member
  8. sdsingh commented on Feb 26, 2016

    @sdsingh

    Sorry, I was incorrect. HOG takes the resulting layer with the highest norm.

  9. stefanv commented on Feb 26, 2016

    @stefanv
    Member
  10. pradyumnanpk commented on Feb 26, 2016

    @pradyumnanpk
    Contributor

    I am trying to implement this feature. Let me know if my understanding is correct.
    If a color image is given, then HOG is calculated on individual channels (R, G and B) and the HOG for the channel with highest norm is returned.
    I am implementing this feature based on my understanding as stated above. Please correct me if I am wrong.

  11. pradyumnanpk commented on Feb 27, 2016

    @pradyumnanpk
    Contributor

    I implemented the HOG for color images based on the excerpt from the original paper "For colour images, we calculate separate gradients for each colour channel, and take the one with the largest norm
    as the pixel’s gradient vector"[Dalal and Triggs] and the CVPR presentation "For color image, pick the color channel with the highest gradient magnitude for each pixel"[Dalal and Triggs].

    I implemented the functionality such that gradient magnitude is calculated for each channel and for each pixel, the gradient vector with maximum magnitude is considered. Let me know if I implemented it correctly.

    I want to write a test case to test the correctness of color image. Can someone help me regarding this.

  12. added this to the 0.14 milestone on Nov 4, 2017
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

    ⏩ type: Enhancement

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions