Is sift algorithm invariant in color?

What have you tried so far? You could verify this with an experiment such as..

import cv2
img = cv2.imread('0.jpg',1) # 1 = read image as color
sift = cv2.xfeatures2d.SIFT_create()
kp = sift.detect(img,None)
img2 = cv2.drawKeypoints(img,kp,None)
cv2.imwrite('siftkpcolor.jpg',img2)

Then you can run the code again with the same image and do

import cv2
img = cv2.imread('0.jpg',0) # 0 = read image as gray
sift= cv2.xfeatures2d.SIFT_create()
kp = sift.detect(img,None)
img2 = cv2.drawKeypoints(img,kp,None)
cv2.imwrite("siftkpgray.jpg",img2)

Now you will have two images saved, one in color with keypoints drawn and another in gray with keypoints drawn. What do you see? I tried the above code with

>>>cv2.__version__
3.1.0-dev

Check my images below. This may not be as fined-grained as you want but it's a start. Most image processing applications tend to use grayscale because it is much less data to crunch than a full color image.

For a reference check these tutorials:

  1. why we should use gray scale for image processing
  2. http://docs.opencv.org/3.1.0/da/df5/tutorial_py_sift_intro.html
  3. http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_gui/py_image_display/py_image_display.html

Color KP

Gray KP


SIFT operates on grayscale images only. In the conclusion of Lowe's paper, he notes:

The features described in this paper use only a monochrome intensity image, so further distinctiveness could be derived from including illumination-invariant color descriptors (Funt and Finlayson, 1995; Brown and Lowe, 2002).

The OpenCV implementation converts color images to grayscale images before extracting features.

static Mat createInitialImage( const Mat& img, bool doubleImageSize, float sigma )
{
    /* ... */
    Mat gray, gray_fpt;
    if( img.channels() == 3 || img.channels() == 4 )
    {
        cvtColor(img, gray, COLOR_BGR2GRAY);
        gray.convertTo(gray_fpt, DataType<sift_wt>::type, SIFT_FIXPT_SCALE, 0);
    }
    else
        img.convertTo(gray_fpt, DataType<sift_wt>::type, SIFT_FIXPT_SCALE, 0);
    /* ... */
}