필터 지우기
필터 지우기

How to make continuous contour line discrete?

조회 수: 2 (최근 30일)
Ivan Shorokhov
Ivan Shorokhov 2015년 3월 13일
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