在MATLAB中绘制形状上下文logpolar-bins

在MATLAB中绘制形状上下文logpolar-bins,matlab,machine-learning,computer-vision,pattern-recognition,shape-context,Matlab,Machine Learning,Computer Vision,Pattern Recognition,Shape Context,我使用形状上下文直方图作为特征描述符来编码轮廓图像。为了帮助调试,我想查看覆盖在轮廓图像(从边缘图像获取的采样点)上的形状上下文logpolar bins 其中一个点的外观示例如下所示: 我知道如何显示圆形(径向箱),但在生成角度箱(直线)时遇到困难 给定一组角度,如何绘制与示例图像中所示类似的线段?执行此操作: >> figure >> axes >> hold on >> radius = 1; >> theta = 0:30:360; >> for angle = theta line([

我使用形状上下文直方图作为特征描述符来编码轮廓图像。为了帮助调试,我想查看覆盖在轮廓图像(从边缘图像获取的采样点)上的形状上下文logpolar bins

其中一个点的外观示例如下所示:

我知道如何显示圆形(径向箱),但在生成角度箱(直线)时遇到困难

给定一组角度,如何绘制与示例图像中所示类似的线段?

执行此操作:

>> figure >> axes >> hold on >> radius = 1; >> theta = 0:30:360; >> for angle = theta line([0 radius * cosd(angle)], [0 radius * sind(angle)]); end >>身材 >>斧头 >>等一下 >>半径=1; >>θ=0:30:360; >>对于角度=θ 直线([0半径*余弦(角度)],[0半径*余弦(角度)]; 结束 产生以下结果:


您可以使用此功能:

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
见结果:


谢谢您的快速回答!这正是我想要的:——)