how to show points on image in matlab?

后端 未结 3 878
我寻月下人不归
我寻月下人不归 2021-02-20 07:31

i have some pixel points lets say p1(1,1) and p2(1,10).......and so on

i want to display these points on image in any color. how to do this?

3条回答
  •  盖世英雄少女心
    2021-02-20 08:07

    MATLAB plot documentation is pretty comprehensive.

    LineSpec properties lists the syntax for different styles of lines, colors, and points.

    If you want more options, see LineSeries Properties. You can specify properties such as Marker (style), MarkerEdgeColor, MarkerFaceColor, and MarkerSize.

    You can also use RGB triplets to define color, if you want to deviate from rgbcmykw.

    Examples:

    Plot a single point (3,4) with an orange five-pointed star marker:

    p=[3,4];
    plot(p(1),p(2),'Marker','p','Color',[.88 .48 0],'MarkerSize',20)
    

    Plot an array of points with green 'o' markers:

    p=round(10*rand(2,10));
    plot(p(1,:),p(2,:),'go')
    

    EDIT: If you've got all your points stored as p1=[x1,y1], p2=[x2,y2], etc., try reorganizing them into a 2xN matrix first. Either re-generate the points, or if you've already got them as single pairs, use

    p=[p1;p2;p3]'; %# the [;] notation vertically concatenates into Nx2, 
                   %# and the ' transposes to a 2xN
    plot(p(1,:),p(2,:),'go')
    

    Or, if you have a ton of points stored as single pairs, say up to p1000 or so, you could use eval (cringe).

    p=[]; %# initialize p
    for n=1:nPoints %# if you've got 1000 points, nPairs should be 1000
    eval(['p(:,n)=p',num2str(n)],''); %#executes p(:,n)=pn' for each nPoint
    end
    

提交回复
热议问题