Borrar filtros
Borrar filtros

How to make continuous contour line discrete?

2 visualizaciones (últimos 30 días)
Ivan Shorokhov
Ivan Shorokhov el 13 de Mzo. de 2015
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!

Respuestas (0)

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by