meanshift.mht

来自「camshift算法matlab版」· MHT 代码 · 共 74 行

MHT
74
字号
From: <由 Microsoft Internet Explorer 5 保存>
Subject: 
Date: Tue, 26 Jun 2007 15:57:21 +0800
MIME-Version: 1.0
Content-Type: text/html;
	charset="gb2312"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://bbs.matwav.com/user/download/166534/meanshift.m
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
<META content=3D"MSHTML 6.00.2900.3086" name=3DGENERATOR></HEAD>
<BODY><PRE>% Adam Kukucka
% Zach Clay
% Marcelo Molina   =20
% CSE 486 Project 3

function [ rowcenter colcenter M00 ] =3D meanshift(I, rmin, rmax, =
cmin,...
    cmax, probmap)
%inputs
%   rmin, rmax, cmin, cmax are the coordiantes of the window
%   I is the image
%outputs
%   colcenter rowcenter are the new center coordinates
%   Moo is the zeroth mean

% **********************************************************************
% initialize
% **********************************************************************

M00 =3D 0; %zeroth mean
M10 =3D 0; %first moment for x
M01 =3D 0; %first moment for y
histdim =3D (0:1:255); % dimensions of histogram... 0 to 255, increment =
by 1
[rows cols] =3D size(I);
cols =3D cols/3; % **********************8

% **********************************************************************
% Main code
% **********************************************************************


% determine zeroth moment
for c =3D cmin:cmax
    for r =3D rmin:rmax
        M00 =3D M00 + probmap(r, c);
    end
end

% determine first moment for x(col) and y(row)
for c =3D cmin:cmax
    for r =3D rmin:rmax
        M10 =3D M10 + c*probmap(r,c);
        M01 =3D M01 + r*probmap(r,c);
    end
end

% determine new centroid
% x is cols

    colcenter =3D M10/M00;

% y is rows

    rowcenter =3D M01/M00;



</PRE></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?