How to make continuous contour line discrete?

2 次查看(过去 30 天)
Dear all,
I have a contour of a circle. I want to decimate (downsample) it to 50 samples of original contour. What is the best way of doing it. Right now I have 51 sample instead of 50 due to ' floor ' function.
Here is the code I'm using right now:
close all; clear all;clc;
o_circ = imread('circle.jpg');
bw_circ = im2bw(o_circ, graythresh(o_circ));
cont = contour(bw_circ, [0,0], 'r.',...
'LineWidth',2); close;
[row, col]=size(cont);
down_cont1=downsample(cont(1,:),floor(col/50),1); down_cont2=downsample(cont(2,:),floor(col/50),1);
figure; ax1=subplot(1,2,1); imshow(o_circ); hold on; cont = contour(bw_circ, [0,0], 'r.',...
'LineWidth',2); title('Original contour');
ax2=subplot(1,2,2); imshow(o_circ); hold on; plot(down_cont1, down_cont2, 'r*',...
'LineWidth',2); title('Downsampled contour'); axis([ax1 ax2],'tight');
And here is the result:
Thanks in advance for any help!

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by