Create different outline colors for different times

조회 수: 1 (최근 30일)
Alex Perrakis
Alex Perrakis 2021년 11월 9일
댓글: Alex Perrakis 2021년 11월 9일
Hello, i have written following code, which creates an Image of outlines of some photos i took for my project,
The question ist , can i insert a time variable to insert the colour of the outlines depending on time? Thanks for the answer guys!
pic01=imread("1.tiff");
pic1=im2gray(pic01);
i=1;
boundaries=[];
for i=3:7:69;
pic050=im2gray( imread(i+".tiff") );
%pic50=im2gray(pic050);
newpicture=imsubtract(pic01,pic050);
%imshow(newpicture)
level = graythresh(newpicture);
level = 0.1405;
newbinpic = imbinarize(newpicture,level);
%imshowpair(newpicture,newbinpic,'montage')
newbinpic2=bwpropfilt(newbinpic,'perimeter',1);
% imshowpair(newbinpic2,newpicture,'montage');
boundariesi = bwboundaries(newbinpic2);
boundaries=[boundaries; boundariesi];
binaryImage = 0.6< newbinpic2 & newbinpic2<1;
end
% figure; imshow(pic01);
hold on
for k=1:length(boundaries)
thisBoundary = boundaries{k};
x = thisBoundary(:,2);
y = thisBoundary(:,1);
plot(x,y,'r-','Linewidth',2);
end
grid off

채택된 답변

Joseph Cheng
Joseph Cheng 2021년 11월 9일
you can generate a color scale by using the different types of colors like hsv, jet, bone, gray, etc. then depending on the time sements or whatever your desire of colors are you can then get that color. see example of each time step has a different color:
t = 0:.1:1; %setup time
clors= hsv(numel(t)); %create a color map of different color for each time
figure(1),clf,hold on
for ind =1:numel(t)
plot(t,t(ind)*t,'Color',clors(ind,:)); %dummy plot to show that each plotted line changes color
end
hold off

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by