Ask Your Question
0

How does the SiftDescriptorExtractor convert descriptor values?

asked 2013-02-16 09:11:14 -0600

this post is marked as community wiki

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

I have a question about the last part of the SiftDescriptorExtractor job,

I'm doing the following:

    SiftDescriptorExtractor extractor;
    Mat descriptors_object;
    extractor.compute( img_object, keypoints_object, descriptors_object );

Now I want to check the elements of a descriptors_object Mat object:

std::cout<< descriptors_object.row(1) << std::endl;

output looks like:

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 32, 15, 0, 0, 0, 0, 0, 0, 73, 33, 11, 0, 0, 0, 0, 0, 0, 5, 114, 1, 0, 0, 0, 0, 51, 154, 20, 0, 0, 0, 0, 0, 154, 154, 1, 2, 1, 0, 0, 0, 154, 148, 18, 1, 0, 0, 0, 0, 0, 2, 154, 61, 0, 0, 0, 0, 5, 60, 154, 30, 0, 0, 0, 0, 34, 70, 6, 15, 3, 2, 1, 0, 14, 16, 2, 0, 0, 0, 0, 0, 0, 0, 154, 84, 0, 0, 0, 0, 0, 0, 154, 64, 0, 0, 0, 0, 0, 0, 6, 6, 1, 0, 1, 0, 0, 0]

But in Lowe paper it is stated that:

Therefore, we reduce the influence of large gradient magnitudes by thresholding the values in the unit feature vector to each be no larger than 0.2, and then renormalizing to unit length. This means that matching the magnitudes for large gradients is no longer as important, and that the distribution of orientations has greater emphasis. The value of 0.2 was determined experimentally using images containing differing illuminations for the same 3D objects.

So the numbers from the feature vector should be no larger than 0.2 value.

The question is, how these values have been converted in a Mat object?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-02-16 09:40:39 -0600

Guanta gravatar image

Having a look in the modules/nonfree/src/sift.cpp it seems that this normalization is applied but not between 0 and 1 but as uchar values, thus ranging from 0-255. I'm not quite sure about the reason for that. Maybe discrete values are better later on for the comparison. If you need them between 0 and 1 either normalize them again (cv::normalize()) or adjust lines 634-638 in sift.cpp (OpenCV version 2.4.3).

edit flag offensive delete link more

Comments

Thanks for the answer! still, for example I have n descriptors with 128 values (between 0 and 1) each. How can I put them in Mat object? mat_descriptor_object.at<uchar> (n,j) = value*255; like this?

valgussev gravatar imagevalgussev ( 2013-02-16 12:30:00 -0600 )edit

If 'value' is between 0 and 1 then this would be a way to convert it to a uchar-Matrix. Probably I would have written sth like: Mat1b ucharMat = 255*floatMat; (if floatMat contains only floats between 0 and 1). Alternatively: floatMat.convertTo(ucharMat, ucharMat.type(), 255);

Guanta gravatar imageGuanta ( 2013-02-17 08:07:17 -0600 )edit

but descriptors_object should be a Mat object, how to convert float to cv::Mat?

valgussev gravatar imagevalgussev ( 2013-02-17 09:19:20 -0600 )edit

Excuse me, but I don't understand your question. Your descriptors_object is a matrix of type CV_32FC1 , however the values in it are actually ranging between 0 and 255. If you need them to range between 0 and 1 you can apply one of the solutions of my answer.

Guanta gravatar imageGuanta ( 2013-02-17 09:55:47 -0600 )edit

no no no, I'm not talking about values between 0 and 1, just let's forget about them. Now I'm asking about lines 634-638 in sift.cpp. After these lines we have dst with 128 values inside of it ranging between 0 and 255. My question is how to put these 128 values in a descriptors_object?

valgussev gravatar imagevalgussev ( 2013-02-17 10:09:53 -0600 )edit

They are already in it. The dst float-array is one row of the descriptors-Matrix. See line 658 where the function to calculate the descriptor is called with one specific ptr of row of the descriptor-Matrix.

Guanta gravatar imageGuanta ( 2013-02-17 10:23:24 -0600 )edit

now i got it, thank you!

valgussev gravatar imagevalgussev ( 2013-02-17 11:50:37 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-02-16 09:11:14 -0600

Seen: 1,586 times

Last updated: Feb 16 '13