# How to use SIFT with a color inverted image

This post is a wiki. Anyone with karma >50 is welcome to improve it.

For example I have two images, where first one is a regular and second one with a color inversion (I mean 255 - pixel color value).

I've applied SIFT algorithm to both of them, so now I have key points and descriptors of each image.

KeyPoints positions do match, but KeyPoints orientations and Descriptors values do not, because of color inversion.

I'm curious do anybody try to solve such a problem?

edit retag close merge delete

Sort by » oldest newest most voted

The gradients should have the opposite direction. That is, the orientation ori' = (ori + 180) % 360 (assuming that ori is in [0°, 360°]. Most likely the orientation is in [-180°, 180°]; you have to adapt the equation appropriately.)

Following that the resulting SIFT descriptor of the inverted image is a permutation of the original SIFT descriptor. To obtain it you have to swap the descriptor bins of the original bin and the bin associated with the opposite direction. It is probably the easiest to draw it first an sheet of paper to see the effect of gradient inversion.

more

Do you mean by "gradient direction" keypoint orientation on which descriptor orientation depends? What do you mean by "swap the contents"? We have 8 bins histogram for each 16 regions (8x4x4=128), you mean to switch values of the opposite bins? for example 1st and 5th, 2nd and 6th?

( 2013-02-23 11:08:49 -0500 )edit

The gradient direction is the direction of the gradients as gradients are defined in their mathematical sense. This then applies to both the orientation assigned to the interest point as well as to the gradients that are interpolated and binned into the SIFT descriptor bins. By "swap the contents" I meant that you effectively have to swap bins. There is no need to recompute the SIFT descriptor a simple permutation of the already compute bins will do.

( 2013-02-24 05:41:43 -0500 )edit

thanks for the explanation, but as you can see here i.stack.imgur.com/XRfdh.png gradients are not absolutely opposite

( 2013-02-24 06:58:08 -0500 )edit

That looks odd indeed. I would first test this on a simple black and white image that only contains simple shapes as a circle, triangles and rectangles.

( 2013-02-24 08:49:36 -0500 )edit

Looks the same.. http://i.stack.imgur.com/fY2PR.png But when I subtract 180 or add 180 (within [0, 360]) looks like http://i.stack.imgur.com/Oniad.png , interesting

( 2013-02-24 09:07:24 -0500 )edit

Official site

GitHub

Wiki

Documentation