I will use sift in identifying a certain type of object what if that object change in color can it recognize it? i will use opencv library for sift cv2.xfeatures2d.SIFT_create()
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);
/* ... */
}
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With