Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing shape context logpolar bins in MATLAB

I am using shape context histograms as a feature descriptor to encode silhouette images. To assist with debugging, I would like to view the shape context logpolar bins overlaid on a silhouette image (the sample points taken from the edge image).

An example of what it should look like for one of the points is as follows: Overlaid shape context logpolar bins

I know how to display the circles (radial bins), but I am having difficulty in producing the angular bins (lines).

Given a set of angles, how can I draw line segments similar to those shown in the example image?

like image 419
Josh Avatar asked Mar 10 '11 11:03

Josh


2 Answers

You can use this function:

function scDrawPolar(samp,point,r_min,r_max,nbins_theta,nbins_r)
%SCDRAWPOLAR draw a polar on the center point
%   point           - the 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
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

See the result here:

figure screenshot

like image 102
nn0p Avatar answered Oct 23 '22 08:10

nn0p


Doing this:

>> figure
>> axes
>> hold on
>> radius = 1;
>> theta = 0:30:360;
>> for angle = theta
line([0 radius * cosd(angle)], [0 radius * sind(angle)]);
end

produces this:

enter image description here

like image 35
b3. Avatar answered Oct 23 '22 09:10

b3.