<commit_before>---
layout: post
title: 计算机视觉快速特征描述子Dense SIFT
date: 2015-12-16
categories: ML
tags: [Dense SIFT,特征描述子]
description: Machine Learning相关

---


![Dense SIFT.png](http://upload-images.jianshu.io/upload_images/1174946-87a7914a8274b357.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

VLFeat implements a [fast dense version of SIFT](http://www.vlfeat.org/api/dsift.html), called [vl_dsift](http://www.vlfeat.org/matlab/vl_dsift.html)
. The function is roughly equivalent to running SIFT on a dense gird of locations at a fixed scale and orientation. This type of feature descriptors is often uses for object categorization.
###Dense SIFT as a faster SIFT
The main advantage of using [vl_dsift](http://www.vlfeat.org/matlab/vl_dsift.html)
 over [vl_sift](http://www.vlfeat.org/matlab/vl_sift.html)
 is speed. To see this, load a test image
I = vl_impattern('roofs1') ;I = single(vl_imdown(rgb2gray(I))) ;

To check the equivalence of vl_disft
 and [vl_sift](http://www.vlfeat.org/matlab/vl_sift.html)
 it is necessary to understand in detail how the parameters of the two descriptors are related.
**Bin size vs keypoint scale**. DSIFT specifies the descriptor size by a single parameter, size
, which controls the size of a SIFT spatial bin in pixels. In the standard SIFT descriptor, the bin size is related to the SIFT keypoint scale by a multiplier, denoted magnif
 below, which defaults to 3
. As a consequence, a DSIFT descriptor with bin size equal to 5 corresponds to a SIFT keypoint of scale 5/3=1.66.

**Smoothing.** The SIFT descriptor smoothes the image according to the scale of the keypoints (Gaussian scale space). By default, the smoothing is equivalent to a convolution by a Gaussian of variance s^2 - .25
, where s
 is the scale of the keypoint and .25
 is a nominal adjustment that accounts for the smoothing induced by the camera CCD.

Thus the following code produces equivalent descriptors using either DSIFT or SIFT:
binSize = 8 ;magnif = 3 ;Is = vl_imsmooth(I, sqrt((binSize/magnif)^2 - .25)) ;[f, d] = vl_dsift(Is, 'size', binSize) ;f(3,:) = binSize/magnif ;f(4,:) = 0 ;[f_, d_] = vl_sift(I, 'frames', f) ;

The difference, of course, is that DSIFT is much faster.
![](http://upload-images.jianshu.io/upload_images/1174946-d37ff13771df6ecb.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![](http://upload-images.jianshu.io/upload_images/1174946-5f3776040db78a26.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)Left: accuracy of the slow and fast dense SIFT implementations in [vl_dsift](http://www.vlfeat.org/matlab/vl_dsift.html)
 compared to the SIFT baseline from vl_sift
. Right: speedup. The fast version is less similar to the original SIFT descriptors but from 30 to 70 times faster than SIFT. Notice that the equivalence of the descriptors does not necessarily indicate that one would work better than the other in applications.

PHOW descriptors<commit_msg>change blog file<commit_after>---
layout: post
title: 计算机视觉快速特征描述子Dense SIFT
date: 2015-12-16
categories: ML
tags: [Dense SIFT,特征描述子]
description: Machine Learning相关

---


![Dense SIFT.png](http://upload-images.jianshu.io/upload_images/1174946-87a7914a8274b357.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

VLFeat implements a [fast dense version of SIFT](http://www.vlfeat.org/api/dsift.html), called [vl_dsift](http://www.vlfeat.org/matlab/vl_dsift.html)
. The function is roughly equivalent to running SIFT on a dense gird of locations at a fixed scale and orientation. This type of feature descriptors is often uses for object categorization.
###Dense SIFT as a faster SIFT
The main advantage of using [vl_dsift](http://www.vlfeat.org/matlab/vl_dsift.html)
 over [vl_sift](http://www.vlfeat.org/matlab/vl_sift.html)
 is speed. To see this, load a test image
I = vl_impattern('roofs1') ;I = single(vl_imdown(rgb2gray(I))) ;

To check the equivalence of vl_disft
 and [vl_sift](http://www.vlfeat.org/matlab/vl_sift.html)
 it is necessary to understand in detail how the parameters of the two descriptors are related.
**Bin size vs keypoint scale**. DSIFT specifies the descriptor size by a single parameter, size
, which controls the size of a SIFT spatial bin in pixels. In the standard SIFT descriptor, the bin size is related to the SIFT keypoint scale by a multiplier, denoted magnif
 below, which defaults to 3
. As a consequence, a DSIFT descriptor with bin size equal to 5 corresponds to a SIFT keypoint of scale 5/3=1.66.

**Smoothing.** The SIFT descriptor smoothes the image according to the scale of the keypoints (Gaussian scale space). By default, the smoothing is equivalent to a convolution by a Gaussian of variance s^2 - .25
, where s
 is the scale of the keypoint and .25
 is a nominal adjustment that accounts for the smoothing induced by the camera CCD.

Thus the following code produces equivalent descriptors using either DSIFT or SIFT:
binSize = 8 ;magnif = 3 ;Is = vl_imsmooth(I, sqrt((binSize/magnif)^2 - .25)) ;[f, d] = vl_dsift(Is, 'size', binSize) ;f(3,:) = binSize/magnif ;f(4,:) = 0 ;[f_, d_] = vl_sift(I, 'frames', f) ;

The difference, of course, is that DSIFT is much faster.

![](http://upload-images.jianshu.io/upload_images/1174946-d37ff13771df6ecb.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 

![](http://upload-images.jianshu.io/upload_images/1174946-5f3776040db78a26.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)Left: accuracy of the slow and fast dense SIFT implementations in [vl_dsift](http://www.vlfeat.org/matlab/vl_dsift.html)

 compared to the SIFT baseline from vl_sift
. Right: speedup. The fast version is less similar to the original SIFT descriptors but from 30 to 70 times faster than SIFT. Notice that the equivalence of the descriptors does not necessarily indicate that one would work better than the other in applications.

PHOW descriptors
{'fraction_non_alphanumeric': 0.09561208809970975, 'fraction_numerical': 0.0382448352398839, 'mean_word_length': 4.771428571428571, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 12, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6190259', 'n_tokens_mistral': 2119, 'n_tokens_neox': 1942, 'n_words': 695}