forked from pdollar/toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotGaussEllipses.m
33 lines (31 loc) · 1.03 KB
/
plotGaussEllipses.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function hs = plotGaussEllipses( mus, Cs, rad )
% Plots 2D ellipses derived from 2D Gaussians specified by mus & Cs.
%
% USAGE
% hs = plotGaussEllipses( mus, Cs, [rad] )
%
% INPUTS
% mus - k x 2 matrix of means
% Cs - 2 x 2 x k covariance matricies
% rad - [2] Number of std to create the ellipse to
%
% OUTPUTS
% hs - handles to ellipses
%
% EXAMPLE
% plotGaussEllipses( [ 10 10; 10 10 ], cat(3,eye(2),eye(2)*2) );
%
% See also PLOTELLIPSE, GAUSS2ELLIPSE
%
% Piotr's Computer Vision Matlab Toolbox Version 2.0
% Copyright 2014 Piotr Dollar. [pdollar-at-gmail.com]
% Licensed under the Simplified BSD License [see external/bsd.txt]
if (nargin<3 || isempty(rad) ); rad=2; end
colors = ['b', 'g', 'r', 'c', 'm', 'y', 'k']; nc = length(colors);
washeld = ishold; if (~washeld); hold('on'); end
hs = zeros( size(mus,1),1 );
for i=1:size( mus,1)
[ cRow, ccol, ra, rb, phi ] = gauss2ellipse( mus(i,:), Cs(:,:,i), rad );
hs(i)=plotEllipse( cRow, ccol, ra, rb, phi, colors( mod(i-1,nc)+1) );
end
if (~washeld); hold('off'); end