/*---
function cw = ic(emag,ephase,ci,cj,mask)
Input:
emag = matrix of image size, edge magnitudes
ephase = phase map for edges, discrete values
[ci,cj] = c index representation for entries in the
pairwise affinity matrix
mask = label matrix of image size, pixels of the same value
have affinity of 1 regardless of emag and ephase
Output:
cw = real vector of the same size as ci,
maximum emag of intervening contours
Stella X. Yu, July 9 2003.
--*/
# include "mex.h"
# include "math.h"
void mexFunction(
int nargout,
mxArray *out[],
int nargin,
const mxArray *in[]
)
{
/* declare variables */
int nr, nc, np, total, to_bias;
int k, a, ai, aj, b, bi, bj, p, pi, pj, q, qi, qj, di, dj, s, step;
double z, maxe, slope;
unsigned int *ci, *cj;
double *emag, *phase, *cw, *mask;
/* check argument */
if (nargin<4) {
mexErrMsgTxt("Four input arguments required");
}
if (nargout>1) {
mexErrMsgTxt("Too many output arguments");
}
/* get pb and phase */
nr = mxGetM(in[0]);
nc = mxGetN(in[0]);
a = mxGetM(in[1]);
b = mxGetN(in[1]);
total = mxGetM(in[2]) * mxGetN(in[2]);
np = mxGetM(in[3]) * mxGetN(in[3]) - 1;
if ( nr != a || nc != b || nr*nc != np || np<=0) {
mexErrMsgTxt("Dimension mismatches between the inputs");
}
emag = mxGetData(in[0]);
phase = mxGetData(in[1]);
/* get the c-index pair */
if (!mxIsUint32(in[2]) || !mxIsUint32(in[3])) {
mexErrMsgTxt("Index pair shall be of type UINT32");
}
ci = mxGetData(in[2]);
cj = mxGetData(in[3]);
/* get the mask */
to_bias = 0;
if (nargin>4) {
a = mxGetM(in[4]);
b = mxGetN(in[4]);
if (a*b>0) {
if (a==nr && b==nc && mxIsDouble(in[4])) {
to_bias = 1;
mask = mxGetData(in[4]);
} else {
mexErrMsgTxt("Incorrect size or type for mask");
}
}
}
/* create output */
out[0] = mxCreateDoubleMatrix(total,1,mxREAL);
if (out[0]==NULL) {
mexErrMsgTxt("Not enough memory for the output matrix");
}
cw = mxGetPr(out[0]);
/* computation */
for (a=0; a<np; a++) {
aj = a / nr; /* col */
ai = a % nr; /* row */
for (k=cj[a]; k<cj[a+1]; k++) {
b = ci[k];
maxe = 0.0;
if (!((a==b) || (to_bias && mask[a]==mask[b] && mask[a]>0 && to_bias))) {
bj = b / nr;
bi = b % nr;
/* (p,q): adjacent pixels moving along the line connecting a and b */
p = a;
pj = aj;
pi = ai;
/* scan */
dj = abs(aj - bj);
di = abs(ai - bi);
if (dj >= di) { /* step along j */
step = (bj>aj) ? 1 : -1;
slope = (float)(bi-ai) / (float)(bj-aj);
for (s=0; s<dj; s++) {
qj = pj + step;
qi = (int) (0.5 + slope * (qj-aj) + ai);
q = qi + qj * nr;
if (1) {
z = emag[p];
if (z>maxe) {
maxe = z;
}
}
p = q;
pj = qj;
pi = qi;
}
} else { /* step along i */
step = (bi>ai) ? 1 : -1;
slope = (float) (bj-aj) / (float)(bi-ai);
for (s=0; s<di; s++) {
qi = pi + step;
qj = (int) (0.5 + slope * (qi-ai) + aj);
q = qi + qj * nr;
if (1) {
z = emag[p];
if (z>maxe) {
maxe = z;
}
}
p = q;
pj = qj;
pi = qi;
}
}
maxe = maxe * 0.5;
}
cw[k] = maxe;
} /* b */
} /* a */
}
没有合适的资源?快使用搜索试试~ 我知道了~
superPixels算法
4星 · 超过85%的资源 需积分: 6 30 下载量 118 浏览量
2009-08-05
12:46:35
上传
评论 1
收藏 46KB GZ 举报
温馨提示
共30个文件
m:14个
mexmac:5个
c:5个
一个现在很流行的图像分割技术,基于边缘检测的superPixels分割
资源详情
资源评论
资源推荐
收起资源包目录
superpixels.tar.gz (30个子文件)
superpixels
yu_imncut
parmatV.c 2KB
csparse.mexmac 9KB
gaussian.m 697B
computeW.m 2KB
spmd.mexmac 9KB
csparse.c 2KB
imnb.mexmac 9KB
parmatV.mexmac 9KB
make_filterbank_odd2.m 864B
ic.mexmac 9KB
doog1.m 505B
cncut.m 2KB
imnb.c 4KB
fft_filt_2.m 664B
ic.c 4KB
getbinsol.m 1KB
NOTE 114B
spmd.c 3KB
img_000070.jpg 25KB
dist2.m 888B
segImage.m 193B
sp_demo.m 1KB
sp_demo.m~ 1KB
imncut_sp.m 5KB
pbWrapper.m 1KB
README 1KB
imncut_sp.m~ 5KB
pbThicken.m 234B
README~ 1KB
clusterLocations.m 906B
共 30 条
- 1
happythy
- 粉丝: 2
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于thinkphp5/weui/layui的简易投票系统,适用于社团/班级投票选举
- 基于Spring +mybatis的投票系统 支持单选多选,统计信息等
- 基于pandas、Scikit-Learn、matplotlib、PyQt5的二手房价分析与预测系统
- 基于 yolov5 和 PyQt5 开发工具搭建了实时违法检测区域入侵软件,支持自定义检测区域、多种对象检测以及事件信息统计
- ZG202220101014胡雪梅.zip
- 姥娘家菜单修改最新再做500张.cdr
- 基于Python实现的英雄联盟知识图谱的问答
- 密码学算法之SHA-1
- 基于Python实现联邦学习框架下基于Memae的异常检测架构
- 密码学之DES加密算法
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论4