/* MEX file to rank relevant images using WEIGHTED probabilistic distance
*
* Created by: Minh Do, 7 July 1999
*
* To compile:
* mex -O -v rankwpd.c
*
* Note: This is different with rankpd.c in that it takes into the account
* on the entropy weights from the query image.
*/
#include "mex.h"
#include <stdlib.h>
#include <math.h>
/* From Numerical Recipes */
double gammaln(double xx)
{
double x,y,tmp,ser;
static double cof[6]={76.18009172947146,-86.50532032941677,
24.01409824083091,-1.231739572450155,
0.1208650973866179e-2,-0.5395239384953e-5};
int j;
y=x=xx;
tmp=x+5.5;
tmp -= (x+0.5)*log(tmp);
ser=1.000000000190015;
for (j=0;j<=5;j++) ser += cof[j]/++y;
return -tmp+log(2.5066282746310005*ser/x);
}
/* Symmetric Kullback-Leibler distance between
* two generalized Gaussian pdf's
*/
double kldistS(double a1, double b1, double a2, double b2)
{
double res;
res = pow(a1/a2, b2)*exp(gammaln((b2+1.0)/b1)-gammaln(1.0/b1)) - 1.0/b1
+ pow(a2/a1, b1)*exp(gammaln((b1+1.0)/b2)-gammaln(1.0/b2)) - 1.0/b2;
return ((res > 0.0) ? res : 0.0);
}
/* Asymmetric Kullback-Leibler distance between
* two generalized Gaussian pdf's
* (a1, b1) is the query parameters
* (a2, b2) is the candidate image parameters
* Result is:
* KLD((a1,b1) || (a2,b2)) or KLD(query || image)
*/
double kldistA(double a1, double b1, double a2, double b2)
{
double res;
res = log((b1 * a2) / (b2 * a1)) + gammaln(1.0/b2) - gammaln(1.0/b1)
+ pow(a1/a2, b2)*exp(gammaln((b2+1.0)/b1)-gammaln(1.0/b1)) - 1.0/b1;
return ((res > 0.0) ? res : 0.0);
}
/* Kullback-Leibler distance between two feature vectors
* fv1 is supposed to be from the query image
* fv2 is supposed to be from the candidate image
* ws is the weigths (computed from the query image)
*/
double probdist(double *fv1, double *fv2, double *w, int nb)
{
/* Assumption on features:
a, b, a, b, (next level), ...
for total nb pairs corresponding to nb subbands
*/
int i;
double dist = 0.0;
for (i = 0; i < nb; i++)
dist += w[i] * kldistA(fv1[2*i], fv1[2*i+1], fv2[2*i], fv2[2*i+1]);
return dist;
}
/* function rr = rankwpd(fs, ws, ns)
% RANKWPD Rank relevant images using WEIGHTED probabilistic distance
%
% Input:
% fs: feature sets, one column per image
% ws: entropy weights, one column per image
% ns: (optional), number of subimages per texture class
% (default 16)
%
% Output:
% rr: rank of relevant images, one column for each query
%
% See also: RANKED
*
**/
void
mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
double *fs;
double *ws;
double *rr;
int nimages, ns, nb, nf;
int q, i, c, r;
double *dist, dr;
double *pr;
fs = mxGetPr(prhs[0]);
nf = mxGetM(prhs[0]);
nb = nf / 2; /* 2 features per band */
nimages = mxGetN(prhs[0]);
ws = mxGetPr(prhs[1]);
if ((mxGetM(prhs[1]) != nb) || (mxGetN(prhs[1]) != nimages))
mexErrMsgTxt("Matrix dimensions mismatched");
if (nrhs < 3)
ns = 16;
else
ns = (int) *(mxGetPr(prhs[2]));
/* Create/allocate output */
plhs[0] = mxCreateDoubleMatrix(ns, nimages, mxREAL);
rr = mxGetPr(plhs[0]);
/* Array to keep distances */
dist = (double *) malloc(nimages * sizeof(double));
/* Simulate Query by Example process */
for (q = 0; q < nimages; q++) /* each query */
{
for (i = 0; i < nimages; i++) /* each image */
dist[i] = probdist(fs + q*nf, fs + i*nf, ws + q*nb, nb);
c = q / ns; /* class index of the query */
/* Find the rank of the relevant images */
for (r = 0; r < ns; r++)
{
pr = rr + q * ns + r; /* pointer to the corresponding rank */
dr = dist[c * ns + r]; /* distance of the relevant image */
*pr = 1; /* restart */
for (i = 0; i < nimages; i++)
if (dist[i] < dr)
(*pr)++;
}
}
free(dist);
}
没有合适的资源?快使用搜索试试~ 我知道了~
rct.zip_decomposition_modulate2( )_rct_zip
共91个文件
m:63个
mat:9个
mexw64:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 169 浏览量
2022-09-20
23:34:29
上传
评论
收藏 837KB ZIP 举报
温馨提示
Redundant contourlet decomposition
资源推荐
资源详情
资源评论
收起资源包目录
rct.zip (91个子文件)
rct
rankwpd.c 4KB
fmm_rct_L1.mat 38KB
rctfeat_all.m 2KB
contourlet_toolbox
denoisedemo.m 2KB
pdfb_nest.m 931B
computescale.m 5KB
Nadia.m 485B
sefilter2.m 1KB
backsamp.m 1KB
Nadia.asv 481B
pdfbdec.m 3KB
SNR.m 248B
mctrans.m 882B
reverse2.m 167B
resamp.m 1KB
wfb2dec.m 1KB
pdown.m 1KB
pdfb2vec.m 1KB
ldfilter.m 662B
dfbdec.m 2KB
fbdec_l.m 1KB
pup.m 2KB
lprec.m 935B
qprec.m 2KB
resampc.mexsol 6KB
rebacksamp.m 1KB
resampc.mexmac 9KB
dfbrec.m 2KB
dup.m 755B
fbdec.m 2KB
ld2quin.m 856B
resampc.mexw64 10KB
ppdec.m 1KB
resampc.mexw32 7KB
resampz.m 2KB
README 3KB
Contents.m 3KB
pdfbrec.m 1KB
pdfb_tr.m 1KB
efilter2.m 1KB
nlademo2.m 1KB
resampc.c 2KB
dfilters.m 3KB
extend2.m 2KB
dfbimage.m 2KB
fbrec.m 2KB
lpdec.m 722B
decdemo.m 3KB
qpdec.m 1KB
smthborder.m 930B
resampc.dll 7KB
resampc.mexlx 6KB
nlademo.m 5KB
modulate2.m 775B
qup.m 2KB
dfbrec_l.m 2KB
pfilters.m 2KB
vec2pdfb.m 1KB
ChangeLog 2KB
ffilters.m 485B
pprec.m 1KB
zoneplate.png 51KB
showpdfb.m 13KB
qupz.m 1KB
fbrec_l.m 1KB
dfbdec_l.m 2KB
qdown.m 2KB
COPYING 706B
resampc.mexglx 7KB
wfb2rec.m 1KB
rankpd.mexw64 9KB
run_rctfeat.m 3KB
fml_rct_L3.mat 114KB
fmm_rct_L3.mat 114KB
VisTex.m 878B
rankwpd.mexmac 13KB
fml_rct_L1.mat 38KB
fm_rct_L1.mat 38KB
rankwpd.mexw64 9KB
fmm_rct_L2.mat 76KB
Rcontourl_decomp.m 2KB
fm_rct_L2.mat 76KB
rankwpd.mexlx 8KB
rankwpd.mexsol 12KB
Laplace_redundant
sefilter2.m 1KB
extend2.m 2KB
Lapredundant.m 5KB
Rlaplace_rec.m 1KB
fml_rct_L2.mat 76KB
rctfeat.m 3KB
fm_rct_L3.mat 114KB
共 91 条
- 1
资源评论
我虽横行却不霸道
- 粉丝: 75
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功