/*=================================================================
% perform_geometry_testing_slow - test all geometry using an Alpert transform
%
% coef = perform_geometry_testing(pos, v, G_list, monomials);
%
% Copyright (c) 2004 Gabriel Peyr�
*=================================================================*/
#include <math.h>
#include "mex.h"
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include "../../toolbox_wavelets/mex/perform_haar_transform.h"
#include "../../toolbox_wavelets/mex/perform_79_transform.h"
#include "../../toolbox_alpert/mex/perform_moment_transform.h"
/* Global variables */
int n; // size
double* G_list = NULL;
double** v_list = NULL;
int v_list_size = -1;
double* coef = NULL;
int d = -1; // number of dimension for the geometry
int nb_geo = -1; // number of geometry tested
// for here, warped position are stored in pos
// and not-warped in poso (original position)
double* poso = NULL;
double* pos = NULL;
#define posr pos
/* needed by perform_moment_transform */
double* v = NULL;
double* w = NULL;
double* monomials = NULL;
double** part = NULL;
int* G = NULL;
int* si = NULL;
void perform_warping(const double* pos, double* posw, double* g, int n, int d)
{
#define pos_x(i) pos[2*i+eps_x]
#define pos_y(i) pos[2*i+eps_y]
int eps_x = 0;
int eps_y = 1;
// if g(1), swap x and y
if( g[0]==2 )
{
eps_x = 1;
eps_y = 0;
}
// warp each point
for( int i=0; i<n; ++i )
{
double xi = pos_x(i);
double yi = pos_y(i);
// evaluate the polynomial : a+b*x+c*x^2
double w = g[1] + g[2]*xi;
if( d==2 ) // quadratic polynomials
w += g[3]*xi*xi;
// g[0]=1 : (x, y-w(x))-->(y-w(x),x) and g[0]=2 : (y-w(x), x)-->(y-w(x),x)
posw[2*i] = yi-w;
posw[2*i+1] = xi;
}
}
inline
int fncompare_haar(const void * elem1, const void * elem2 )
{
#define posrx_(i) posr[ 0+(i)*2 ]
#define posry_(i) posr[ 1+(i)*2 ]
int n1 = *((int*) elem1);
int n2 = *((int*) elem2);
if( posrx_(n1)<posrx_(n2) )
return -1;
else if ( posrx_(n1)==posrx_(n2) )
{
// use y axis to divide tie
if( posry_(n1)<posry_(n2) )
return -1;
else
return 1;
}
else
return 1;
}
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray*prhs[] )
{
/* retrieve arguments */
if( nrhs<4 )
mexErrMsgTxt("4 input arguments are required.");
if( nlhs!=1 )
mexErrMsgTxt("1 output arguments are required.");
// first argument : poso
int tmp = mxGetM(prhs[0]);
n = mxGetN(prhs[0]);
if( tmp!=2 )
mexErrMsgTxt("pos must be of size 2xn.");
poso = mxGetPr(prhs[0]);
// second input : v_list
const mxArray* mx_v_list = prhs[1];
if( !mxIsCell(mx_v_list) )
mexErrMsgTxt("v must be a cell array.");
v_list_size = mxGetNumberOfElements(mx_v_list);
v_list = new double*[v_list_size];
// construct v_list
for( int i=0; i<v_list_size; ++i )
{
mxArray* vi = mxGetCell(mx_v_list, i);
if( vi==NULL )
mexErrMsgTxt("error in v retrieving.");
tmp = mxGetNumberOfElements(vi);
if( tmp!=n )
mexErrMsgTxt("All element in v{} must be of size n.");
v_list[i] = mxGetPr(vi);
}
// third argument : G_list, of size dx2
d = mxGetM(prhs[2])-2;
if( d!=1 && d!=2 )
mexErrMsgTxt("G_list must be of size (d+2)xnb_geo with d==1 or d==2.");
nb_geo = mxGetN(prhs[2]);
G_list = mxGetPr(prhs[2]);
// fourth argument : monomials
int k = mxGetN(prhs[3]);
monomials = mxGetPr(prhs[3]);
// first ouput : coef of size nb_geo x n
plhs[0] = mxCreateDoubleMatrix(n*v_list_size, nb_geo, mxREAL);
coef = mxGetPr(plhs[0]);
// minimum scale for 1D transforms
int Jmin = 1;
// warped position
posr = new double[n*2];
int* I = NULL;
double* vv = NULL;
if( monomials[0]<0 )
{
I = new int[n];
vv = new double[n];
// initialize the order of sampling points
for( int i=0; i<n; ++i )
I[i] = i;
}
// perform transform for each geometry
for( int i=0; i<nb_geo; ++i )
{
double* g = &G_list[i*(d+2)];
// perform warping
perform_warping(poso, posr, g, n, d);
// compute the ordering of the X direction
if( monomials[0]<0 )
qsort(I, n, sizeof(int), fncompare_haar);
// perform the transform for each cell
for( int j=0; j<v_list_size; ++j )
{
v = v_list[j];
w = &coef[i*v_list_size*n + j*n];
// perform the transform
if( monomials[0]<0 )
{
// sort the v values according to the sampling location
// the array 0:n-1 to reorder
for( int i=0; i<n; ++i )
vv[i] = v[I[i]];
if( monomials[0]==-1 )
{
// use haar transform
perform_haar_transform_1d(vv, w, n, Jmin, 1);
}
else if( monomials[0]==-4 )
{
// copy vv to w (in place transform)
memcpy( w, vv, n*sizeof(double) );
perform_79_transform_1d( w, n, Jmin, 1 );
}
else
{
mexErrMsgTxt("Only Haar and 7-9 transforms implemented for the moment.");
}
}
else
{
// use alpert transform
perform_moment_transform( n, -1, k, 1 );
}
}
}
GW_DELETEARRAY(I);
GW_DELETEARRAY(vv);
}
没有合适的资源?快使用搜索试试~ 我知道了~
bandelets工具箱
共66个文件
m:42个
dll:3个
vcproj:3个
5星 · 超过95%的资源 需积分: 10 24 下载量 176 浏览量
2010-04-23
08:55:10
上传
评论 1
收藏 56KB ZIP 举报
温馨提示
第三代小波之一,希望对研究小波的人员给予帮助!!!!
资源推荐
资源详情
资源评论
收起资源包目录
toolbox_bandelets.zip (66个子文件)
toolbox_bandelets
test_mex.m 4KB
sample_geometry.m 2KB
perform_quatree_list_creation.m 3KB
perform_bandelet_transform.m 2KB
perform_bandelet_transform_wavelets.m 1KB
subimage_compute_parameters.m 5KB
CVS
Entries 2KB
Entries.Extra 897B
Repository 34B
Root 43B
subimage_compute_parameter_nogeom.m 2KB
perform_parameter_optimization_slow.m 3KB
quadtree_cart_optimization.m 3KB
perform_warping.m 722B
perform_quatree_list_creation_wavelets.m 949B
perform_geometry_testing.dll 12KB
mex
perform_geometry_testing.def 59B
CVS
Entries 688B
Entries.Extra 349B
Repository 38B
Root 43B
bandelet.sln 2KB
config.h 5KB
perform_parameter_optimization.vcproj 4KB
gram_schmidt.h 898B
perform_geometry_testing.cpp 5KB
gram_schmidt.def 49B
gram_schmidt.cpp 990B
perform_parameter_optimization.cpp 4KB
perform_parameter_optimization.def 65B
gram_schmidt.vcproj 4KB
perform_geometry_testing.vcproj 4KB
quadtree_sum.m 911B
test_monores.m 2KB
callback_quadtree_display.m 2KB
toolbox
gen_signal.m 602B
psnr.m 359B
get_color_from_index.m 241B
evaluate_nbr_bits.m 689B
norme.m 159B
perform_haar_transform_slow.m 2KB
convert_wavelets2list.m 3KB
keep_above.m 340B
perform_haar_transform.dll 5KB
compute_distance_to_points.m 548B
compute_quadrant_selection.m 857B
compute_error_threshold.m 414B
evaluate_nbr_bits_wavelets.m 784B
dirac.m 361B
reverse_permutation.m 277B
rescale.m 265B
keep_biggest.m 600B
perform_parameter_optimization.dll 5KB
quadtree_tag_below_leaf.m 1KB
perform_geometry_testing_slow.m 1KB
perform_parameter_optimization.m 1KB
perform_quadtree_transform.m 5KB
plot_projected_curve.m 694B
readme 82B
plot_quadtree.m 4KB
perform_geometry_testing.m 201B
plot_linreg_wavband.m 2KB
quadtree_init.m 2KB
plot_geometry.m 1024B
compile_mex.m 126B
quadtree_cart_init.m 3KB
共 66 条
- 1
资源评论
- 爱吃爱和2013-06-21是学习新一代小波的很好的工具,认真学习
- fcdxei2013-06-12编译时提示缺少toolbox_wavelets,于是还要去下载小波工具箱
qweert_123
- 粉丝: 2
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功