Wednesday, October 31, 2007

Visual Assist真是好用

忍受了半年没有Visual Assist的日子,终于又装回来了…发现Visual Assist真是能极大的提高开发效率,不过这毕竟是一种投机取巧的方法,总是怀着矛盾,如果总用,没有Visual之后不就成了傻子了?
类似的情况也体现在Windows/linux的选择上……便捷,还是痛苦一点也许有好处?

不过对于我们code只是一种辅助手段的情况来说,还是注重效率第一位,因为还有很多其他的事情要做

Tuesday, October 30, 2007

Ransac算法原理

Ransac是一种非常简单的算法
用于在一群样本中去掉噪声样本,得到有效的样本
采用随机抽样验证的方法
以下节选自wikipedia,选有用的贴了过来

RANSAC
RANSAC is an abbreviation for "RANdom SAmple Consensus". It is an algorithm to estimate parameters of a mathematical model from a set of observed data which contains outliers. The algorithm was first published by Fischler and Bolles in 1981.
A basic assumption is that the data consists of "inliers", i.e., data points which can be explained by some set of model parameters, and "outliers" which are data points that do not fit the model. In addition to this, the data points can be subject to noise. The outliers can come, e.g., from extreme values of the noise or from erroneous measurements or incorrect hypotheses about the interpretation of data. RANSAC also assumes that, given a (usually small) set of inliers, there exists a procedure which can estimate the parameters of a model that optimally explains or fits this data.

Example
A simple example is fitting of a 2D line to set of observations. Assuming that this set contains both inliers, i.e., points which approximately can be fitted to a line, and outliers, points which cannot be fitted to this line, a simple least squares method for line fitting will in general produce a line with a bad fit to the inliers. The reason is that it is optimally fitted to all points, including the outliers. RANSAC, on the other hand, can produce a model which is only computed from the inliers, provided that the probability of choosing only inliers in the selection of data points is sufficiently high. There is no guarantee for this situation, however, and there are a number of algorithm parameters which must be carefully chosen to keep the level of probability reasonably high.



Overview
The input to the RANSAC algorithm is a set of observed data values, a parameterized model which can explain or be fitted to the observations, and some confidence parameters.
RANSAC achieves its goal by iteratively selecting a random subset of the original data points. These points are hypothetical inliers and this hypothesis is then tested as follows. A model is fitted to the hypothetical inliers, that is, all free parameters of the model are reconstructed from the point set. All other data points are then tested against the fitted model, that is, for every point of the remaining set, the algorithm determines how well the point fits to the estimated model. If it fits well, that point is also considered as a hypothetical inlier. If sufficiently many points have been classified as hypothetical inliers relative to the estimated model, then we have a model which is reasonably good. However, it has only been estimated from the initial set of hypothetical inliers, so we reestimate the model from the entire set of point's hypothetical inliers. At the same time, we also estimate the error of the inliers relative to the model.
This procedure is then repeated a fixed number of times, each time producing either a model which is rejected because too few points are classified as inliers or a refined model together with a corresponding error measure. In the latter case, we keep the refined model if its error is lower than the last saved model.

Algorithm
The generic RANSAC algorithm works as follows:

input:
data - a set of observed data points
model - a model that can be fitted to data points
n - the minimum number of data values required to fit the model
k - the maximum number of iterations allowed in the algorithm
t - a threshold value for determining when a data point fits a model
d - the number of close data values required to assert that a model fits well to data
output:
bestfit - model parameters which best fit the data (or nil if no good model is found)
iterations := 0
bestfit := nil
besterr := infinity
while iterations <> d
(this implies that we may have found a good model now test
how good it is)
bettermodel := model parameters fitted to all points in maybeinliers and alsoinliers
thiserr := a measure of how well model fits these points
if thiserr <>
increment iterations
return bestfit


While the parameter values of t and d have to be calculated from the individual requirements it can be experimentally determined. The interesting parameter of the RANSAC algorithm is k.
To calculate the parameter k given the known probability w of a good data value, the probability z of seeing only bad data values is used:
which leads to
To gain additional confidence, the standard deviation or multiples thereof can be added to k. The standard deviation of k is defined as
A common case is that w is not well known beforehand, but some rough value can be given. If n data values are given, the probability of success is wn.


Advantages and disadvantages
An advantage of RANSAC is its ability to do robust estimation of the model parameters, i.e., it can estimate the parameters with a high degree of accuracy even when outliers are present in the data set. A disadvantage of RANSAC is that there is no upper bound on the time it takes to compute these parameters. If an upper time bound is used, the solution obtained may not be the most optimal one.
RANSAC can only estimate one model for a particular data set. As for any one-model approach when more two (or more) models exist, RANSAC may fail to find either one.

Applications
The RANSAC algorithm is often used in computer vision, e.g., to simultaneously solve the correspondence problem and estimate the fundamental matrix related to a pair of stereo cameras.

References
M. A. Fischler and R. C. Bolles (June 1981). "Random Sample Consensus: A Paradigm for Model Fitting with Applications to Image Analysis and Automated Cartography". Comm. of the ACM 24: 381--395. doi:10.1145/358669.358692.
David A. Forsyth and Jean Ponce (2003). Computer Vision, a modern approach. Prentice Hall. ISBN ISBN 0-13-085198-1.
Richard Hartley and Andrew Zisserman (2003). Multiple View Geometry in Computer Vision, 2nd edition, Cambridge University Press.

Monday, October 29, 2007

总结一下:在国内访问blogspot博客的方法


blogspot抽筋式被盾,经常是只能写不能读,如何在国内浏览世界最大的blog网站,还是有很多人动了很多脑筋的……
以下以本人的http://tonysh-thu.blogspot.com为例

1. 单一blogspot网站,单一计算机
这种方式不容易,但是非常有效,比如只是想在自己的计算机上访问自己的blogspot网站
需要修改本地域名解析系统,
在%SystemRoot%system32driversetchost文件中最后加入一行:

72.14.219.190 tonysh-thu.blogspot.com

然后重启机器
这样一劳永逸解决问题,但好像在vista机器上这个方法不管用

2. 所有blog网站,单一计算机
原理类似上面的方法,使用代理脚本,不需要其他网站的协助,可以直接访问blogspot的任何一个blog,方法如下:
编辑文本文件,内容为:
function FindProxyForURL(url,host) {
if(dnsDomainIs(host, ".blogspot.com")) {
return "PROXY 72.14.219.190:80";
}
}
命名为(比如)a.pac,放在(比如)c:根目录下。pac代表是代理脚本的文件类型。
IE:在菜单栏上选择 工具-Internet选项-连接,里面有一个设置按钮,是用来设置代理服务器的,点开。在“使用自动配置脚本”前面打钩,然后在激活的文本框里输入上面保存的脚本的路径(上例中为c:a.pac)。确定。
firefox:依次点击工具-选项-高级-网络-设置,选中自动代理配置URL,添加:file:///C:/a.pac ,点击重新载入。
搞定

3. 一般化方法:访问代理网站
主要原理是通过其他网站匿名访问,或是重定向域名,我测试过的有:

a)访问:
http://anonymouse.org/cgi-bin/anon-www.cgi/http://tonysh-thu.blogspot.com
特点是匿名访问,需要出国流量,域名奇长难记,但anonymous.org是个好东西,可以匿名访问任何网站。
b)访问:
http://tonysh-thu.blogspot.com.nyud.net:8090/
不需要出国流量,比较方便,速度不慢,推荐!
c)访问:
http://www.pkblogs.com/tonysh-thu/
我没有测试成功-_-b网上说可以的啊

4. FTP方法
blogspot支持FTP方式发布管理贴子,用这种方法申请一个FTP
可以直接访问,但据说非常之麻烦