Znn3bq.jpeg
²é¿´: 1421  |  »Ø¸´: 8

xmcrobbie

Òø³æ (СÓÐÃûÆø)

[ÇóÖú] ÓжγÌÐò£¬¾Í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)];


ÎÒ²»ÖªµÀÕâ¸öº¯ÊýÆðʲô×÷Óð¡¡£¡£¡£¡£
»Ø¸´´ËÂ¥

» ²ÂÄãϲ»¶

» ±¾Ö÷ÌâÏà¹Ø¼ÛÖµÌùÍÆ¼ö£¬¶ÔÄúͬÑùÓаïÖú:

ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

haier20022

гæ (ÕýʽдÊÖ)

¡¾´ð°¸¡¿Ó¦Öú»ØÌû

¸Ðл²ÎÓ룬ӦÖúÖ¸Êý +1
ÊÇmatlab³ÌÐò°É£¿
2Â¥2013-10-20 13:33:29
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

feixiaolin

ÈÙÓþ°æÖ÷ (ÎÄ̳¾«Ó¢)

ÓÅÐã°æÖ÷

function Y = sampleWithR(weights,K)
% ÒÀÈ¨ÖµÖØ²ÉÑù£»
cdf = cumsum(weights);
% ȨֵÀÛ¼Ó
Y = histc(rand(K,1)*cdf(end),[0; cdf]);
% ͳ¼ÆÖ±·½Í¼
Y = [Y(1:end-2); Y(end-1)+Y(end)];
% Ö±·½Í¼×îĩһbinÐÞÕý
3Â¥2013-10-20 14:40:26
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

xmcrobbie

Òø³æ (СÓÐÃûÆø)

ÒýÓûØÌû:
3Â¥: Originally posted by feixiaolin at 2013-10-20 14:40:26
function Y = sampleWithR(weights,K)
% ÒÀÈ¨ÖµÖØ²ÉÑù£»
cdf = cumsum(weights);
% ȨֵÀÛ¼Ó
Y = histc(rand(K,1)*cdf(end),);
% ͳ¼ÆÖ±·½Í¼
Y = ;
% Ö±·½Í¼×îĩһbinÐÞÕý...

Y = histc(rand(K,1)*cdf(end),[0; cdf]);  ÕâÐв»Àí½â°¡¡£rand£¨K£¬1£©ÊÇËæ»ú²úÉúK¸ö0µ½1µÄÊý°É¡£[0; cdf] Ó¦¸ÃÊÇÔÚÔÚcdf2ǰ¼Ó¸ö0°É¡£

Ó¦¸ÃÊÇ¿´¿´²úÉúµÄÕâK¸öÊý£¬ÂäÔÚͳ¼ÆÖ±·½Í¼Öи÷¸öbinµÄ¸öÊý°É¡£¡£¡£

ÕâôÀí½â¶ÔÂð£¿
4Â¥2013-10-20 16:30:32
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

coolslj

½ð³æ (ÕýʽдÊÖ)

¡¾´ð°¸¡¿Ó¦Öú»ØÌû

¡ï ¡ï ¡ï ¡ï ¡ï
¸Ðл²ÎÓ룬ӦÖúÖ¸Êý +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
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

xmcrobbie

Òø³æ (СÓÐÃûÆø)

ÒýÓûØÌû:
5Â¥: Originally posted by coolslj at 2013-10-21 08:20:40
Generates K samples from the discrete distribution specified by weights
¸ù¾ÝÀëÉ¢·Ö²¼½øÐвÉÑù£¬¸Ã·Ö²¼ÓÃÑù±¾È¨Öرíʾ

rand(K,1)*cdf(end)µÄÄ¿µÄÊÇ£º½«²úÉúµÄ0-1Ö®¼äµÄËæ»úÊý£¬·ÅËõµ½ÉÏÊöÀëÉ¢·Ö²¼£¨ÒòÎªÈ¨ÖØ ...

ʵ¼ÊÉÏY¾ØÕóÊÇËæ»úÊýÔÚweighsÖ±·½Í¼µÄ·Ö²¼£¬YµÄÖµweighsµÄÖµ²¢Ã»ÓÐÖ±½Ó¹ØÏµ£¬²»ÖªµÀÕâÑù×Ó²ÉÑùÓÐʲôÒâÒå¡£
6Â¥2013-10-21 15:10:19
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

coolslj

½ð³æ (ÕýʽдÊÖ)

ÒýÓûØÌû:
6Â¥: Originally posted by xmcrobbie at 2013-10-21 15:10:19
ʵ¼ÊÉÏY¾ØÕóÊÇËæ»úÊýÔÚweighsÖ±·½Í¼µÄ·Ö²¼£¬YµÄÖµweighsµÄÖµ²¢Ã»ÓÐÖ±½Ó¹ØÏµ£¬²»ÖªµÀÕâÑù×Ó²ÉÑùÓÐʲôÒâÒå¡£...

Â¥Ö÷ûÓÐÌṩ¸Ã³ÌÐòµÄ±³¾°ºÍÉÏÏÂÎÄ£¬ËùÒÔר¼ÒÃÇÓеãäÈËÃþÏó¡£

¸Ã³ÌÐò¸ù¾ÝÒ»¸ö·Ö²¼µÄÖ±·½Í¼£¬²úÉúÁËÒ»¸öеķֲ¼µÄÖ±·½Í¼¡£
´ÓÕâ¸ö½Ç¶È¿´£¬¸Ã³ÌÐòÎÞʵ¼ÊÒâÒå¡£
ÎÒÍÆ²âËüÖ÷ÒªÊÇÓÃÓÚ½Ìѧ¡£
7Â¥2013-10-22 12:50:06
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

xmcrobbie

Òø³æ (СÓÐÃûÆø)

ÒýÓûØÌû:
7Â¥: Originally posted by coolslj at 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)/2len-1)/2].^2/(.4*len.^2);
xx = [-(wid-1)/2wid-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
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

xmcrobbie

Òø³æ (СÓÐÃûÆø)

´úÂëÌ«³¤£¬×¨¼ÒÃÇÓпհïÎÒ¿´¿´Ã´£¬ÎÒ¿´ÁËÒ»¸öÐÇÆÚÁË£¬»¹ÊÇû¸ã¶®£¡
9Â¥2013-10-22 14:34:02
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû
Ïà¹Ø°æ¿éÌø×ª ÎÒÒª¶©ÔÄÂ¥Ö÷ xmcrobbie µÄÖ÷Ìâ¸üÐÂ
×î¾ßÈËÆøÈÈÌûÍÆ¼ö [²é¿´È«²¿] ×÷Õß »Ø/¿´ ×îºó·¢±í
[¿¼ÑÐ] ÉúÎïÓëÒ½Ò©µ÷¼Á +5 Ê®Æßsa 2026-04-05 5/250 2026-04-10 08:14 by kangsm
[¿¼ÑÐ] Ò»Ö¾Ô¸ ½­ÄÏ´óѧ 085602 »¯¹¤×¨Ë¶ 338·ÖÇóµ÷¼Á +16 ·³ÕСç÷ 2026-04-05 16/800 2026-04-10 08:08 by kangsm
[¿¼ÑÐ] ²ÄÁÏר˶³õÊÔ·Ö332Ò»Ö¾Ô¸Î÷±±¹¤Òµ´óѧ£¬ +12 ¹ÊÈË?? 2026-04-09 12/600 2026-04-09 18:34 by Ccclqqq
[¿¼ÑÐ] 296Çóµ÷¼Á +5 Íô£¡£¿£¡ 2026-04-09 5/250 2026-04-09 17:47 by ÄûÃʲ»Ëázy
[¿¼ÑÐ] Çóµ÷¼Á²ÄÁÏ¿ÆÑ§Ó빤³ÌÒ»Ö¾Ô¸985³õÊÔ365·Ö +5 ²Ä»¯Àî¿É 2026-04-08 5/250 2026-04-09 17:00 by Lilly_Li
[¿¼ÑÐ] 280Çóµ÷¼Á +7 wzzzÍõ 2026-04-09 7/350 2026-04-09 15:32 by ÊÍ·ÅÌìÐÔ
[¿¼ÑÐ] 070300»¯Ñ§279Çóµ÷¼Á +17 ¹þ¹þ¹þ^_^ 2026-04-08 18/900 2026-04-09 10:49 by ÈýÆßÆßÏëÉϰ¶
[¿¼ÑÐ] ÇóÖú071001µ÷¼Á£¡£¡£¡ +7 »ÆÊØËÉ 2026-04-05 8/400 2026-04-09 09:07 by ÐìÁ¼°×ü´óÏÀ
[¿¼ÑÐ] ²ÄÁÏ334Çóµ÷¼Á +21 Eecho# 2026-04-03 21/1050 2026-04-08 22:55 by Öí»á·É
[¿¼ÑÐ] »¯Ñ§0703-Ò»Ö¾Ô¸211-338·ÖÇóµ÷¼Á +10 vants 2026-04-05 11/550 2026-04-08 16:02 by screening
[¿¼ÑÐ] Çóµ÷¼Á Ò»Ö¾Ô¸Î÷ÄϽ»Í¨´óѧ085701»·¾³¹¤³Ì 282·Ö +15 ¶à¶à°®³Ôºº±¤ 2026-04-04 16/800 2026-04-08 11:39 by i_cooler
[¿¼²©] ²©Ê¿ÉêÇë +3 IQwQl 2026-04-05 3/150 2026-04-07 20:31 by greychen00
[¿¼ÑÐ] 318Çóµ÷¼Á +5 ÀîÇàɽɽɽ 2026-04-07 5/250 2026-04-07 18:24 by À¶ÔÆË¼Óê
[¿¼ÑÐ] 328Çóµ÷¼Á +4 ghhh88888 2026-04-06 5/250 2026-04-07 14:45 by ghhh88888
[ÂÛÎÄͶ¸å] Decision: Revise for Editor»¹»áËÍÉóÂð 100+3 CccccccccFD 2026-04-04 5/250 2026-04-07 10:58 by ±±¾©À³ÒðÈóÉ«
[¿¼ÑÐ] ¿¼Ñе÷¼Á +7 15615482637 2026-04-04 7/350 2026-04-06 22:56 by chenzhimin
[¿¼ÑÐ] 26×ÔÈ»µØÀíѧ303·ÖÇóµ÷¼Á +4 Ò»Õ½³É˶°¡°¡°¡° 2026-04-06 9/450 2026-04-06 20:35 by lin-da
[¿¼ÑÐ] ר˶304ÕÒµ÷¼Á£¬Ò»Ïß³ÇÊÐ×îºÃ +3 ÀîlslÀî 2026-04-05 3/150 2026-04-06 12:16 by ffffjjjj
[¿¼ÑÐ] 272Çóµ÷¼Á +4 Ëɰس£Çà5 2026-04-03 4/200 2026-04-04 17:03 by babysonlkd
[¿¼ÑÐ] 317·Ö Ò»Ö¾Ô¸½­ÄÏ´óѧ »¯Ñ§¹¤³Ìѧ˶ Çóµ÷¼Á +6 YinTai 2026-04-03 6/300 2026-04-03 22:30 by Î޼ʵIJÝÔ­
ÐÅÏ¢Ìáʾ
ÇëÌî´¦ÀíÒâ¼û