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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147830/image.bmp)
Thanks in advance for any help!
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!