You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
skimage.feature.hog only accepts greyscale images #1879
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
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?
@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.
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.
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.
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.
Activity
ivoflipse commentedon Jan 21, 2016
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?
siddarth-jay commentedon Jan 21, 2016
The documentation indicates that RGB is accepted, but the function does throw a "ValueError: The parameter
imagemust 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?
JDWarner commentedon Jan 21, 2016
@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 tohog.siddarth-jay commentedon Jan 22, 2016
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.
sdsingh commentedon Feb 25, 2016
I agree with @siddarth-jay: the original paper computes gradients on each channel, and takes the max over each channel's gradient to recombine.
stefanv commentedon Feb 25, 2016
sdsingh commentedon Feb 26, 2016
Sorry, I was incorrect. HOG takes the resulting layer with the highest norm.
stefanv commentedon Feb 26, 2016
pradyumnanpk commentedon Feb 26, 2016
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.
pradyumnanpk commentedon Feb 27, 2016
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.