Serge Belongie worked people, such as the shape of the context code [1] does not show polar map, and statistical two-dimensional histogram, I added some code, adjust the algorithm when looking more comfortable, also convenient analysis ~
The code is as follows (not quite canonical):
% SC_COMPUTE.M Last change is as follows by Visionfans @ 2011.05.03% for N=1:nsamp FZN=FZ (n,:) &in_vec; Sn=sparse (Theta_array_q (N,FZN), R_array_q (N,FZN), 1,nbins_theta,nbins_r); BH (n,:) =sn (:) '; sctest (); end
It calls a SCTEST.M script file with the following contents:
% of polar plots and two-dimensional histogram by Visionfans @ 2011.05.03% percent Draw Polar diagram H = figure (); AXS = subplot (2,1,1); Axis equal; Point = [Bsamp (1,n) Bsamp (2,n)]; Scdrawpolar (Bsamp,point,r_inner*mean_dist,r_outer*mean_dist,nbins_theta,nbins_r); Percent Draw 2d histogram subplot (2,1,2); Axis equal; Hold on; Percent TEMP = flipud (full (Sn)); Imagesc (temp); ColorMap (gray); Axis image; Xlabel (' {/theta} '); Ylabel (' log (r) '); For I=1:size (temp,2) for j=1:size (temp,1) if temp (j,i) text (i,j,sprintf ('%d ', temp (j,i)), ' Color ', ' R '); End end end hold off; Percent pause; Close (h);
Here I call a function scdrawpolar to draw polar plots:
function Scdrawpolar (samp,point,r_min,r_max,nbins_theta,nbins_r)%scdrawpolar draw a polar on the center point% point-t He center point% r_min-min radius% r_max-max radius% Nbins_theta-theta divide% nbins_r-r divide% fig_handle- Draw the diagram on which figure% by Visionfans @ 2011.05.03 GCA; Hold on; Plot (Samp (1,:) ', Samp (2,:) ', ' r. '), Plot (point (1), point (2), ' Ko '), R_bin_edges=logspace (log10 (r_min), log10 (R_max), NBINS_R); % draw Circles th = 0:pi/50:2 * PI; xunit = cos (th); Yunit = sin (th); For I=1:length (r_bin_edges) line (Xunit * r_bin_edges (i) + point (1), Yunit * R_bin_edges (i) + point (2),... ' LineStyle ', ': ', ' Color ', ' k ', ' linewidth ', 1; End% Draw spokes th = (1:nbins_theta) * 2*PI/NBINS_THETA; CS = [cos (th); zeros (1,size (th,2))]; sn = [sin (th); zeros (1,size (th,2))]; Line (R_max*cs + point (1), R_MAX*SN + point (2), ' LineStyle ', ': ', ... ' Color ', ' k ', ' linewidth ', 1); Axis equal; Axis off; Hold off; End
Just thest, make it! References:
[1] Matching with Shape contexts,serge Belongie, Jitendra Malik and Jan puzicha,http://www.eecs.berkeley.edu/research/ Projects/cs/vision/shape/sc_digits.html