| 查看: 1268 | 回复: 8 | |||
[求助]
有段程序,就5,6行,我看了N天了,请教高手
|
|
function Y = sampleWithR(weights,K) %Y = sampleWithR(weights,K) %Generates K samples from the discrete distribution specified by weights %O(K) %Need to handle border effects cdf = cumsum(weights); Y = histc(rand(K,1)*cdf(end),[0; cdf]); Y = [Y(1:end-2); Y(end-1)+Y(end)]; 我不知道这个函数起什么作用啊。。。。 |
» 猜你喜欢
三无产品还有机会吗
已经有3人回复
投稿返修后收到这样的回复,还有希望吗
已经有7人回复
压汞仪和BET测气凝胶孔隙率
已经有4人回复
博士申请都是内定的吗?
已经有14人回复
谈谈两天一夜的“延安行”
已经有13人回复
氨基封端PDMS和HDI反应快速固化
已经有11人回复
之前让一硕士生水了7个发明专利,现在这7个获批发明专利的维护费可从哪儿支出哈?
已经有11人回复
论文投稿求助
已经有4人回复
Applied Surface Science 这个期刊。有哪位虫友投过的能把word模板发给我参考一下嘛
已经有3人回复
投稿精细化工
已经有6人回复
» 本主题相关价值贴推荐,对您同样有帮助:
看到文献中的柱形图画得很漂亮,请教高手,图中的柱形图是用什么软件画的?
已经有12人回复
请教高手,有知道醋酸水溶液中冰醋酸的回收有什么好办法的么 谢谢
已经有18人回复
请看附件旋风分离器结构,请教高手应该怎么划分网格?
已经有29人回复
想自己设计硬件电路并实现,想从零学起,请教高手指点,这方面最好最全的书是什么?
已经有10人回复
请教高手: LJ势中的指数只能是6-12吗?
已经有4人回复
请教高手,帮我看下贴中图片的水体是什么问题,谢谢
已经有19人回复
SDS-PAGE 我的样品没有跑出条带,请教高手!谢谢!
已经有7人回复
请教高手PLATON-SQUEEZE程序的一点小问题
已经有6人回复
【求助】请教高手三价格怎么变成六价铬?
已经有4人回复
【求助】请教高手:有图--化学位移约5.2处的大包峰是什么?
已经有17人回复
【求助】向各位高手请教:如果我想研究分子导线的导电性,应该看什么书,学习什么软件
已经有6人回复
【求助】打开MS,经常出现 openclipboard 失败,请教高手
已经有8人回复
【求助】请问用什么表征手段可以确定我这个物质结构,请高手指点,高金悬赏!
已经有20人回复
【求助】请教高手帮忙,1,5-二溴萘经正丁基锂,锂溴交换上TMS,产率相当低??
已经有17人回复
请教各位高手:开机自启动程序最好不要超过多少?
已经有10人回复
【求助】SAS编程出了错,看不懂,请教高手
已经有8人回复
haier20022
新虫 (正式写手)
- 应助: 23 (小学生)
- 金币: 793.2
- 红花: 1
- 帖子: 488
- 在线: 32.6小时
- 虫号: 2571738
- 注册: 2013-07-29
- 专业: 计算机科学的基础理论
2楼2013-10-20 13:33:29
feixiaolin
荣誉版主 (文坛精英)
-

专家经验: +518 - 信息EPI: 3
- 应助: 942 (博后)
- 贵宾: 1.275
- 金币: 2930
- 散金: 58785
- 红花: 532
- 沙发: 11
- 帖子: 24215
- 在线: 2601.8小时
- 虫号: 2139575
- 注册: 2012-11-21
- 专业: 光学信息获取与处理
- 管辖: 数学
3楼2013-10-20 14:40:26
4楼2013-10-20 16:30:32
coolslj
金虫 (正式写手)
- 应助: 16 (小学生)
- 金币: 1773.5
- 红花: 1
- 帖子: 849
- 在线: 189.7小时
- 虫号: 1553560
- 注册: 2011-12-27
- 专业: 信号理论与信号处理
【答案】应助回帖
★ ★ ★ ★ ★
感谢参与,应助指数 +1
xmcrobbie: 金币+2 2013-11-04 15:32:52
xmcrobbie: 金币+3 2013-11-04 15:33:37
感谢参与,应助指数 +1
xmcrobbie: 金币+2 2013-11-04 15:32:52
xmcrobbie: 金币+3 2013-11-04 15:33:37
|
Generates K samples from the discrete distribution specified by weights 根据离散分布进行采样,该分布用样本权重表示 rand(K,1)*cdf(end)的目的是:将产生的0-1之间的随机数,放缩到上述离散分布(因为权重weights的总和可能不等于1)。不妨假设rand(K,1)返回1,就容易理解它的含义了。 [0; cdf] 的含义与cumsum的具体实现有关。 |
5楼2013-10-21 08:20:40
6楼2013-10-21 15:10:19
coolslj
金虫 (正式写手)
- 应助: 16 (小学生)
- 金币: 1773.5
- 红花: 1
- 帖子: 849
- 在线: 189.7小时
- 虫号: 1553560
- 注册: 2011-12-27
- 专业: 信号理论与信号处理
7楼2013-10-22 12:50:06
|
function res = searchImCostTRandEndc (im,len,wid,MAX_NUM,thresh,currAngles) %[res,respOut] = getSegments (im,frameNum,len,wid,thresh,currAngles) %Searches binary im for patches of size len by wid of white %Randomized version, thresh is the number of examples to return SUPPRESS = 0; SCALE = 1/3; %When we weight the background flanks by .5 %SCALE = 1/2; %We want our final log potentials to be between 0 & 10 %FINAL_SCALE = 1/3; [origY, origX, dummy] = size(im); if ~exist('currAngles'), currAngles = 15:15:360; %currAngles = 15:15:180; end if ~exist('roi'), roi = [1 1;origY origX]; end %Thresh is the number of pixels we're allowing to be misclassified if ~exist('thresh') | isempty(thresh), %thresh = 1*len*wid; thresh = 0; end %Convert to a probability %thresh = exp(-thresh/SCALE); %Add the size of our patch to buffer our ROI roi = round(roi + max([len wid])*[-1 -1;1 1]); %Make sure ROI does not exceed our image dimensions roi(1, = max([1 1],roi(1, );roi(2, = min([origY origX],roi(2, );%dtheta = 15; ddir = 1; %Maybe go back to 2? ddir = min(length(currAngles)-1,ddir); dpos = 1; %Maybe go back to 2? im = im(roi(1,1):roi(2,1),roi(1,2):roi(2,2), ;[imy,imx,dummy] = size(im); %Shift our currentAngle currAngles = -90 - currAngles; [len,wid] = deal(round(len),round(wid)); %im = uint8(im); %wwid = ceil(wid/8); %wwid = 2; %imPatch = [zeros(len,wid) ones(len,wid) zeros(len,wid)]; %Use felzenswchab style likelihood %imPatch = [zeros(wid,wid*3); -ones(len,wid) ones(len,wid) -ones(len,wid); -ones(wid,wid*3)]; yy = [-(len-1)/2 len-1)/2].^2/(.4*len.^2);xx = [-(wid-1)/2 wid-1)/2].^2/(.4*wid.^2);[yy,xx] = ndgrid(yy,xx); kk = exp(-(yy + xx)); kk = kk.*(len*wid/(sum(kk( )));imPatch = [zeros(wid,wid*3); -ones(len,wid) kk -ones(len,wid); -ones(wid,wid*3)]; %yind = 1:len; yind = yind - mean(yind); %xind = 1:wid; xind = xind - mean(xind); %[Y,X] = ndgrid(yind/(5*len),xind/(5*wid)); %imPatch = exp(-Y.^2 + -X.^2); resp = zeros([length(currAngles) imy imx]); for dir = 1:length(currAngles), currAngle = -90 - currAngles(dir); kernal = imrotate(imPatch,currAngle); %kernal = kernal./sum(kernal( ); %kernal = kernal./sum(kernal(kernal > 0)); [mm,nn,dummy] = size(kernal); %currResp = filter2(kernal == 1,im == 0,'valid') + .5*filter2(kernal == 0,im == 1,'valid'); %tmp = filter2(kernal == 1,im == 0,'valid'); tmp = filter2(kernal.*(kernal > 0),im == 0,'valid'); currResp = tmp + .25*filter2(kernal < 0,im == 1,'valid'); indy = ceil(mm/2):imy-floor(mm/2); indx = ceil(nn/2):imx-floor(nn/2); if ~isempty(currResp), %resp(dir,indy,indx) = exp(-currResp/SCALE); %currResp = exp(-currResp/SCALE); currResp = exp(-currResp/(len*wid*SCALE)); %currResp(tmp == sum(kernal( == 1)) = 0;currResp(tmp == sum(kernal(kernal > 0))) = 0; resp(dir,indy,indx) = currResp; end end %keyboard; resp(resp < thresh) = 0; %ord = find(sampleWithR(exp(-resp( /(len*wid)),thresh));%%%%%%%%%%%%在这里调用了sampleWithR%%%%%%% ord = find(sampleWithR(resp( ,MAX_NUM));resp = resp(ord); [resp,I] = sort(resp); resp = flipud(resp); ord = ord(flipud(I)); %ord = ord(I); res.resp = resp; %res.resp = resp.^(1/FINAL_SCALE); [ang i j] = ndgrid(pi/180*currAngles,roi(1,1):roi(2,1), roi(1,2):roi(2,2)); res.resp = resp; ang = ang(ord); res.u = cos(ang); res.v = sin(ang); res.x = j(ord); res.y = i(ord); res.len = len/2*ones(size(resp)); res.w = wid/2*ones(size(resp)); |
8楼2013-10-22 14:30:50
9楼2013-10-22 14:34:02













回复此楼
= max([1 1],roi(1,
len-1)/2].^2/(.4*len.^2);