More curves in one graph

1 view (last 30 days)
Martin Brazda
Martin Brazda on 8 May 2015
Answered: Image Analyst on 28 May 2015
Hi, Could someone give me advice with plot more curves in different colors, I would like to see superposing those curves.. Concretely plot RHO_start for 3 curves in one window. Here is my code:
clear,clc,close all
abc='abc'; cal=18/230;
Results=[]; bold
data=[];
for i=1:3
im=imread(['vz_' num2str(j) abc(i) '.jpg']);
im=imresize(im,0.5);
%figure,imshow(im)
I=rgb2gray(im);
%figure,imshow(I);
J=imadjust(I);
%figure,imshow(J);
T=graythresh (J);
BW=im2bw(J,T);
%figure,imshow(BW);
BWI=1-BW;
%figure,imshow(BWI);
B=imclearborder(BWI);
O=bwareaopen(B,40000);
H=imfill(O,'holes');
L=bwlabel(H);
S=regionprops(L,'Area','Perimeter');
SE=[0 1 0;1 1 1;0 1 0];
%figure,imshow(H);
D=imdilate(H,SE);
E=edge(D,'canny');
%imshow(E);
bound=bwboundaries(E);
%figure,imshow(E);hold on;
for k=1
b=bound{k};
%plot(b(:,2),b(:,1),'r','LineWidth',1.5);
end
for x=1:numel(S)
%plot(S(x).Centroid(1),S(x).Centroid(2),'ro');
end
xx=b(:,2);
yy=b(:,1);
%figure,plot(xx,yy);axis equal;
XX=xx-mean(xx);
YY=yy-mean(yy);
THETA=XX;
RHO=YY;
%figure,plot(XX,YY);axis equal;
[THETA,RHO]=cart2pol(XX,YY);
%figure,polar(THETA,RHO);
%figure,plot(THETA);
%figure,plot(RHO);
RHO_smooth=smooth(RHO,30);
[Mc,Xc]=min(RHO_smooth);
*RHO_start* =[RHO_smooth(Xc:size(RHO_smooth));RHO_smooth(1:Xc)];
tc=1:length(RHO_start);
[~,locsc]=findpeaks(RHO_start,'MinPeakHeight',160,'MinPeakDistance',50);
figure;hold on;
plot(tc,RHO_start);
plot(locsc,RHO_start(locsc),'rv','MarkerFaceColor','r');
grid on;
title('Number of peaks');
xlabel('angle');
ylabel('radius');
data=[data; i (S.Area)*cal^2 (S.Perimeter)*cal];
end
data
As=mean(data(:,2));
Results=[Results; j As];
end
Thanks

Answers (1)

Image Analyst
Image Analyst on 28 May 2015
You can use a 'Color' option in plot. Follow that by 3 numbers in a 1 by 3 array in the range of 0-1, like
plot(x, y, 'Color', [.2, .3, .8], 'LineWidth', 2);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!