Dearl all, I have to normalize a matrix to some number (512).
Exactly, my question is related to feature descriptor matrix which I want to normalize to 512. Actually, I have to import feature descriptor into another program that only accepts feature descriptors that are normalized to 512. But I don't get how to normalize the feature descriptor matrix or what does it mean by normalized to 512. I found normalize function in matlab but I don't know how can I use it for this purpose.
Below is the exact line what program asked and I have to do.
[Descriptor Data] is a npoint x 128 unsigned char matrix.
Note the feature descriptors are normalized to 512.

 채택된 답변

Adam Danz
Adam Danz 2019년 5월 21일

1 개 추천

I know next to nothing about .sift files but if you search for "512" in this link, you'll find the same instructions you shared but it doesn't describe the normalization process.
According to this resource (again, search for "512" on that page), the sift-based descriptors are L2-Normalized and subsequently multiplied by 512, then rounded to the nearest integer. The description also provides a way to verify that normalization was done correctly.
So, what is L2-normalization? It is a regularization method in machine learning that is better described by this site. Previous answers in this forum have shown that L2-Normalization is straightforward to perform in matlab.
Given all of that information, the normalization would look something like this
% v is your vector
vnorm = round(v/norm(v) * 512);
but you'll need to verify that this is correct by diving into the methods on Koen's website (the 2nd link I shared). I want to be clear that this is where I'd start if I were you but by no means am I inserting confidence that this is what your program (which I've never used) requires. Note that this topic was also discussed here and here (search for "512" on those pages) and those reference agree with the above.

댓글 수: 10

jhz
jhz 2019년 5월 23일
편집: jhz 2019년 5월 23일
Hello, thank you for a detailed and helpful answer. Yes you are right I am doing this to import feature points in VisualSfM and copied that line from their website.
I am still reading from the links you shared, though I wanted to share output of the command you mentioned above. It is giving me a strange output which does not look like a sift descriptor. The output vector is a signed interger having both positive and negative interger values.
Here is how I implemented it and please correct me if I did something wrong here.
I = imread('cameraman.tif');
[r, c, p] = size(I);
if p > 1
I = rgb2gray(I);
end
points = detectSURFFeatures(I);
[features, vldPoints] = extractFeatures(I, points, 'FeatureSize', 128,...
'Method', 'SURF');
% imshow(I); hold on;
% plot(points);
for ii = 1:size(features,1)
v = features(ii,:);
normFeatures(ii,:) = round(v/norm(v) * 512);
end
Thank you once again. It was really helpful.
jhz
jhz 2019년 5월 23일
Here is what output look like:
normFeatures.JPG
and here are the workspace variables.
normFeatures_workspace.JPG
Maybe instead of normalizing each row of features individually you're supposed to normalize the entire matrix together.
round(features/norm(features) * 512);
(I'm just taking stabs in the dark but it seems more likely that the entire matrix should be normalized together).
jhz
jhz 2019년 5월 23일
I tried that too but result is almost similar with more zeros and negative values too.
However, I think that each row of the feature descriptor matrix needs to be normalized as it represents the one feature point.
Adam Danz
Adam Danz 2019년 5월 23일
편집: Adam Danz 2019년 5월 23일
As I see it, the problem is that you're expecting an n-by-128 char matrix that is normalized using some specified method but 1) the normalization method is not clear and 2) it could be that the "features" matrix aren't the correct data to be normalizing in the first place.
Are you sure the method should be set to "Surf"? When I run this code below, the feature matrix is already an unsigned integer but it's normalized to 256 (class uint8).
I = imread('cameraman.tif');
corners = detectHarrisFeatures(I);
[features, valid_corners] = extractFeatures(I, corners);
features.Features(1:10)
ans =
1×10 uint8 row vector
198 49 51 44 253 251 70 197 120 58
jhz
jhz 2019년 5월 23일
Yes, its right. Normalization method is not specified and I am not sure about the features matrix (it might be already normalized).
Yes there is no problem in setting method to SURF, by default it is also SURF for SURFPoints.
I tried your code but I got negative values too in the features matrix. How do you get unsigned integer?
Here is the features matrix:
features.JPG
Adam Danz
Adam Danz 2019년 5월 23일
Sorry, I provided the wrong example. I just updated my previous comment to provide the correct example of an unsigned matrix output.
Nevertheless, that shows that extractFeatures() provides different types of outputs depending on the inputs. Note that my inputs are also unsigned in the updated example.
I'm staring to thing that 512 normalization means that the data are set to 2^9 (=512) rather than the uint8 (2^8 = 256) values.
I'm affraid I'm not being much help since my ideas are just stabs in the dark. I've never worked with sift files so I don't know if your data are the correct data or if the normalization process is correct.
jhz
jhz 2019년 5월 28일
Hello, thank you again. Yes you were right that SURF features are not the right data to be normalized. Actually, I tried the same process to normalize the SIFT feature descriptors found using the original sift binary in MATLAB and it worked (I matched temp.key file provided by Lowe in the sift folder and my features files and both are same). It means the SURF 'features' are not the right data to normalize.
But the questions is how they are different than SIFT descriptors and how can I convert SURF 'features' to SIFT descriptors?
Adam Danz
Adam Danz 2019년 5월 28일
I suggest you start a new question on that topic so others might see it. Maybe someone who has experience working with those files can chip in.
jhz
jhz 2019년 5월 30일
I followed your suggestion and poted new question here.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

jhz
2019년 5월 21일

댓글:

jhz
2019년 5월 30일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by