Skip to content

Add different methods for HOG block normalization #2350

Closed

Description

@coderforlife

It would be nice if HOG implemented the other types of normalization mentioned in the paper (including L2-hys, L2-norm, L1-sqrt, and L1-norm). Right now L1-norm is always used and it was the worst method according to the original paper (besides not normalizing at all). Also, the L1-norm is done in an odd way that looks like it was supposed to be one of the other norms but it wasn't quite complete.

The code at https://github.com/scikit-image/scikit-image/blob/master/skimage/feature/_hog.py#L187 could be done like the following (given an argument norm that is equal to 'L1-norm', 'L1-sqrt', 'L2-norm', or 'L2-hys' (and validated earlier):

if norm == 'L1-norm':
    normalised_blocks[y, x, :] = block / (block.sum() + eps)
elif norm == 'L1-sqrt':
    normalised_blocks[y, x, :] = np.sqrt(block / (block.sum() + eps))
elif norm == 'L2-sqrt':
    normalised_blocks[y, x, :] = block / np.sqrt((block*block).sum() + eps)
else: #if norm == 'L2-hys':
    block_norm = np.clip(block / np.sqrt((block*block).sum() + eps)), max=0.2)
    normalised_blocks[y, x, :] = block / np.sqrt((block_norm*block_norm).sum() + eps)

Even if not all of these normalization methods are made available, the default should not be the odd implemented L1-norm that it currently is (except for backwards compatibility I guess).

Activity

  1. coderforlife commented on Oct 21, 2016

    @coderforlife
    Author

    Note: this is referring to block normalization and not image data normalization (which has been deprecated in that function).

  2. coderforlife commented on Oct 21, 2016

    @coderforlife
    Author

    Mistake in my code for the L2-hys, the last line should have block_norm in the numerator (or change all instances of block_norm to block in the last two lines).

  3. soupault commented on Oct 21, 2016

    @soupault
    Member

    @coderforlife Hello! Are you looking for #2040? :)
    Unfortunately, it is still lacking of reviews, so I'd be grateful if you move there and stress the core team members a little 😉.

  4. added
    ⏩ type: Enhancement
    on Oct 21, 2016
  5. coderforlife commented on Oct 21, 2016

    @coderforlife
    Author

    Duplicate of #1345, #2040, and #2335.

  6. soupault commented on Oct 21, 2016

    @soupault
    Member

    Not fixed yet, so I reopen to have this as an extra reminder. 😈

  7. changed the title [-]HOG Normalization[/-] [+]Add different methods for HOG block normalization[/+] on Oct 21, 2016
  8. sciunto commented on Jan 26, 2017

    @sciunto
    Member

    Close by @soupault

  9. NicholasJohnson9149 commented on Sep 5, 2017

    @NicholasJohnson9149

    I seem to be getting this same warning, how do I get ride of it? skimage_deprecation: Default value of block_norm==L1 is deprecated and will be changed to L2-Hys in v0.15
    'be changed to L2-Hys in v0.15', skimage_deprecation)

  10. coderforlife commented on Sep 5, 2017

    @coderforlife
    Author

    @NicholasJohnson9149 This wasn't about a warning, this was about the fact that L1 used to be the only method. To get rid of the warning use a newer block normalization, like the following:

    hog(..., block_norm='L2-Hys')
    
  11. soupault commented on Sep 6, 2017

    @soupault
    Member

    I agree that the warning (as it is currently implemented) is kind of annoying, but I couldn't come up with a more convenient alternative. Setting block_norm to L2-Hys (as @coderforlife already mentioned) should fix the issue.

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions