How to make continuous contour line discrete?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Contour Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!